private void ReceiveCallBack(IAsyncResult ar) { if (_socket == null || !_socket.Connected) { return; } try { byte[] data = (byte[])ar.AsyncState; int length = _socket.EndReceive(ar); if (length > 0) { string str = Encoding.UTF8.GetString(data, 4, data.Length - 4); SubRecvData(ref str, length); MFNetManager.GetInstance().PushRecvData(str); // go on Receive(); } else { //todo 没有接收到数据 } } catch (Exception e) { //todo 加上异常处理 MFLog.LogError(e.ToString()); //uninit(); //SFUtils.logWarning("网络连接中断:" + e.Message); //dispatcher.dispatchEvent(SFEvent.EVENT_NETWORK_INTERRUPTED); } }
private void OnDestroy() { if (!debug) { MFNetManager.GetInstance().DisConnect(); } }
// Use this for initialization private void Start() { if (!debug) { MFNetManager.GetInstance().Connect(); } MFUIMgr.Open <MFLoginView>(); }
public override void Request(MFProtocolId id, params object[] args) { int bookId = (int)args[0]; var package = new MFRequestProtocol <MFGetBookDetailRequest> { header = new MFRequestHeader { protocolId = id, }, data = new MFGetBookDetailRequest { bookId = bookId, }, }; string data = MFJsonSerialzator.Serialize(package); MFNetManager.GetInstance().Send(data); }
public override void Request(MFProtocolId id, params object[] args) { int roomNumber = (int)args[0]; var package = new MFRequestProtocol <MFGetCharacterListRequest> { header = new MFRequestHeader { protocolId = id, }, data = new MFGetCharacterListRequest { roomNumber = roomNumber, }, }; string data = MFJsonSerialzator.Serialize(package); MFNetManager.GetInstance().Send(data); }
public override void Request(MFProtocolId id, params object[] args) { string scriptId = args[0] as string; var package = new MFRequestProtocol <MFCreateRoomRequest> { header = new MFRequestHeader { protocolId = id, }, data = new MFCreateRoomRequest { scriptId = scriptId, }, }; string data = MFJsonSerialzator.Serialize(package); MFNetManager.GetInstance().Send(data); }
public override void Request(MFProtocolId id, params object[] args) { string token = args[0] as string; var package = new MFRequestProtocol <MFQQLoginRequest> { header = new MFRequestHeader { protocolId = id, }, data = new MFQQLoginRequest { tokenId = token, type = PlatformTypeDebug.win, }, }; string data = MFJsonSerialzator.Serialize(package); MFNetManager.GetInstance().Send(data); }
public static void DoRequest <T>(T arg) { string data = MFJsonSerialzator.Serialize(arg); MFNetManager.GetInstance().Send(data); }
// Update is called once per frame private void Update() { MFNetManager.GetInstance().Update(); MFTimer.Update(); }