KLALB V3.6.0 写了一半
This commit is contained in:
@@ -4,6 +4,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.*;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.concurrent.locks.LockSupport;
|
||||
|
||||
import org.kne.cloud.network.klalb.CannotAssociateException;
|
||||
import org.kne.cloud.network.klalb.KLALBVirtualSocket;
|
||||
@@ -33,33 +34,13 @@ public class SocketChannelBridge extends Task{
|
||||
@Override
|
||||
protected void runTask() {
|
||||
try {
|
||||
if(a instanceof KLALBVirtualSocketChannel) {
|
||||
try {
|
||||
((KLALBVirtualSocketChannel) a).associateSocketChannel(b);
|
||||
}catch(CannotAssociateException e) {
|
||||
bridgeAB.runAtNewThread("SocketBridge A->B thread");
|
||||
bridgeBA.runAtNewThread("SocketBridge B->A thread");
|
||||
bridgeAB.waitfortask();
|
||||
bridgeBA.waitfortask();
|
||||
|
||||
}
|
||||
}else if(b instanceof KLALBVirtualSocketChannel){
|
||||
try {
|
||||
((KLALBVirtualSocketChannel) b).associateSocketChannel(a);
|
||||
}catch(CannotAssociateException e) {
|
||||
bridgeAB.runAtNewThread("SocketBridge A->B thread");
|
||||
bridgeBA.runAtNewThread("SocketBridge B->A thread");
|
||||
bridgeAB.waitfortask();
|
||||
bridgeBA.waitfortask();
|
||||
|
||||
}
|
||||
}else {
|
||||
bridgeAB.runAtNewThread("SocketBridge A->B thread");
|
||||
bridgeBA.runAtNewThread("SocketBridge B->A thread");
|
||||
bridgeAB.waitfortask();
|
||||
bridgeBA.waitfortask();
|
||||
|
||||
}
|
||||
Thread ta=bridgeAB.runAtNewThread("SocketBridge A->B thread");
|
||||
Thread tb=bridgeBA.runAtNewThread("SocketBridge B->A thread");
|
||||
while((ta.isAlive()||tb.isAlive())&&a.isOpen()&&b.isOpen()) {
|
||||
LockSupport.parkNanos(1000000L);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
|
||||
Reference in New Issue
Block a user