Esempio n. 1
0
    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);
        }
    }
Esempio n. 2
0
 private void OnDestroy()
 {
     if (!debug)
     {
         MFNetManager.GetInstance().DisConnect();
     }
 }
Esempio n. 3
0
    // Use this for initialization
    private void Start()
    {
        if (!debug)
        {
            MFNetManager.GetInstance().Connect();
        }

        MFUIMgr.Open <MFLoginView>();
    }
Esempio n. 4
0
    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);
    }
Esempio n. 5
0
    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);
    }
Esempio n. 6
0
    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);
    }
Esempio n. 7
0
    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);
    }
Esempio n. 8
0
    public static void DoRequest <T>(T arg)
    {
        string data = MFJsonSerialzator.Serialize(arg);

        MFNetManager.GetInstance().Send(data);
    }
Esempio n. 9
0
 // Update is called once per frame
 private void Update()
 {
     MFNetManager.GetInstance().Update();
     MFTimer.Update();
 }