[]用Socket连接服务器,服务端显示已经有登录,但Event.OPEN没有触发
package tcp
{
import laya.events.Event;
import laya.net.Socket;
import laya.utils.Byte;
public class CConnector extends Socket
{
protected var sendBuf:Byte = null;
protected var recvBuf:Byte = null;
public function CConnector()
{
this.sendBuf = this.output;
this.recvBuf = this.input;
this.on(Event.OPEN, this, OnConnected);
this.on(Event.CLOSE, this, OnDisconnect);
this.on(Event.MESSAGE, this, OnRecv);
this.on(Event.ERROR, this, OnError);
}
public function OnConnected(e:*=null):void
{
trace('OnConnected');
}
public function OnDisconnect(e:*=null):void
{
trace('OnDisconnect');
}
public function OnRecv(data:*=null):void
{
trace('OnRecv');
trace(data);
}
public function OnError(e:Event=null):void
{
trace('OnError');
}
}
}
//这样连接
Network = new CConnector();
Network.connect('127.0.0.1', 30000);
{
import laya.events.Event;
import laya.net.Socket;
import laya.utils.Byte;
public class CConnector extends Socket
{
protected var sendBuf:Byte = null;
protected var recvBuf:Byte = null;
public function CConnector()
{
this.sendBuf = this.output;
this.recvBuf = this.input;
this.on(Event.OPEN, this, OnConnected);
this.on(Event.CLOSE, this, OnDisconnect);
this.on(Event.MESSAGE, this, OnRecv);
this.on(Event.ERROR, this, OnError);
}
public function OnConnected(e:*=null):void
{
trace('OnConnected');
}
public function OnDisconnect(e:*=null):void
{
trace('OnDisconnect');
}
public function OnRecv(data:*=null):void
{
trace('OnRecv');
trace(data);
}
public function OnError(e:Event=null):void
{
trace('OnError');
}
}
}
//这样连接
Network = new CConnector();
Network.connect('127.0.0.1', 30000);
没有找到相关结果
已邀请:
要回复问题请先登录
3 个回复
chrysanthemum
赞同来自:
cuixueying
赞同来自:
chrysanthemum
赞同来自: