乾坤OL 客户端头字节ID 发送
时间:2010-07-21 来源:sxxs001
case THREAD_SOCKETINIT:
gc = (SocketClient) client;//新建一个socket连接
sc = (SocketConnection) Connector.open(gc.getUrl(), 3, true);//设置参数
sc.setSocketOption(SocketConnection.KEEPALIVE, 0);
sc.setSocketOption(SocketConnection.DELAY, 1);
sc.setSocketOption(SocketConnection.LINGER, 5);
dos = sc.openOutputStream();// 打开输出流
//
Game.debug("第一次发送url:" + gc.getUrl());
Game.debug("isF5:" + isF5 + ":" + Game.serverAddressId);
if (isF5) {//如果是连接生产服务器,则发送服务器下发的 分发id
isF5 = false;
dos.write(Game.serverAddressId);
} else
dos.write((5 + 48));//如果是连接登陆服务器 发送固定的分发id
dos.flush();//send
//
dis = sc.openInputStream();//打开接收流
gc.setSendWork(new NetWork(this, THREAD_SENDDATA));//启动发送线程
gc.getSendWork().start();
gc.setReceiveWork(new NetWork(this, THREAD_RECEIVEDATA));//启动接收线程
gc.getReceiveWork().start();
loop = false;
break;
gc = (SocketClient) client;//新建一个socket连接
sc = (SocketConnection) Connector.open(gc.getUrl(), 3, true);//设置参数
sc.setSocketOption(SocketConnection.KEEPALIVE, 0);
sc.setSocketOption(SocketConnection.DELAY, 1);
sc.setSocketOption(SocketConnection.LINGER, 5);
dos = sc.openOutputStream();// 打开输出流
//
Game.debug("第一次发送url:" + gc.getUrl());
Game.debug("isF5:" + isF5 + ":" + Game.serverAddressId);
if (isF5) {//如果是连接生产服务器,则发送服务器下发的 分发id
isF5 = false;
dos.write(Game.serverAddressId);
} else
dos.write((5 + 48));//如果是连接登陆服务器 发送固定的分发id
dos.flush();//send
//
dis = sc.openInputStream();//打开接收流
gc.setSendWork(new NetWork(this, THREAD_SENDDATA));//启动发送线程
gc.getSendWork().start();
gc.setReceiveWork(new NetWork(this, THREAD_RECEIVEDATA));//启动接收线程
gc.getReceiveWork().start();
loop = false;
break;
相关阅读 更多 +