AddEvent() public static method

public static AddEvent ( int _event, ByteBuffer, data ) : void
_event int
data ByteBuffer,
return void
コード例 #1
0
    /// <summary>
    /// 接收到消息
    /// </summary>
    /// <param name="ms"></param>
    void OnReceivedMessage(MemoryStream ms)
    {
        BinaryReader r = new BinaryReader(ms);

        byte[] message = r.ReadBytes((int)(ms.Length - ms.Position));
        NetworkManager.AddEvent(0, message);
    }
コード例 #2
0
ファイル: SocketClient.cs プロジェクト: 737871854/FireMen2
    void OnReceivedMessage(byte[] message)
    {
        ByteBuffer buffer = new ByteBuffer(message);
        int        mainId = buffer.ReadInt();

        NetworkManager.AddEvent(mainId, buffer);
    }
コード例 #3
0
ファイル: SocketClient.cs プロジェクト: atom-chen/wudihanghai
    private void OnReceivedMessage(MemoryStream ms)
    {
        BinaryReader binaryReader = new BinaryReader(ms);

        byte[] buf = binaryReader.ReadBytes((int)(ms.Length - ms.Position));
        NetworkManager.AddEvent(104, new LuaByteBuffer(buf));
    }
コード例 #4
0
    /// <summary>
    /// 丢失链接
    /// </summary>
    void OnDisconnected(DisType dis, string msg)
    {
        Close();   //关掉客户端链接
        int protocal = dis == DisType.EXCEPTION ? Protocal.EXCEPTION : Protocal.DISCONNECT;

        NetworkManager.AddEvent(protocal, null);
    }
コード例 #5
0
 /// <summary>
 /// 连接上服务器
 /// </summary>
 void OnConnect(IAsyncResult asr)
 {
     Debug.Log("连上了");
     outStream = client.GetStream();
     client.GetStream().BeginRead(byteBuffer, 0, MAX_READ, new AsyncCallback(OnRead), null);
     NetworkManager.AddEvent(Protocal.Connect, new ByteBuffer());
 }
コード例 #6
0
    /// <summary>
    /// 接收到消息
    /// </summary>
    /// <param name="ms"></param>
    void OnReceivedMessage(MemoryStream ms)
    {
        BinaryReader r = new BinaryReader(ms);
        byte[] message = r.ReadBytes((int)(ms.Length - ms.Position));

        ByteBuffer buffer = new ByteBuffer(message);
		NetworkManager.AddEvent(Protocal.Message, buffer);
    }
コード例 #7
0
    private void OnReceivedMessage(MemoryStream ms)
    {
        BinaryReader binaryReader = new BinaryReader(ms);

        byte[]     data  = binaryReader.ReadBytes((int)(ms.Length - ms.Position));
        ByteBuffer data2 = new ByteBuffer(data);

        NetworkManager.AddEvent(104, data2);
    }
コード例 #8
0
    /// <summary>
    /// 接收到消息
    /// </summary>
    /// <param name="memoryStream"></param>
    private void OnReceivedMessage(MemoryStream memoryStream)
    {
        var binaryReader = new BinaryReader(memoryStream);
        var message      = binaryReader.ReadBytes((int)(memoryStream.Length - memoryStream.Position));

        var buffer = Encoding.UTF8.GetString(message);

        NetworkManager.AddEvent(Protocal.Message, buffer);
    }
コード例 #9
0
    static int AddEvent(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        int        arg0 = (int)LuaScriptMgr.GetNumber(L, 1);
        ByteBuffer arg1 = LuaScriptMgr.GetNetObject <ByteBuffer>(L, 2);

        NetworkManager.AddEvent(arg0, arg1);
        return(0);
    }
コード例 #10
0
ファイル: SocketClient.cs プロジェクト: snowyyj001/kcploumiao
    /// <summary>
    /// 丢失链接
    /// </summary>
    void OnDisconnected(DisType dis, string msg)
    {
        Close();   //关掉客户端链接
        int protocal = dis == DisType.Exception ?
                       Protocal.Exception : Protocal.Disconnect;

        NetworkManager.AddEvent(protocal.ToString(), new LuaByteBuffer(new byte[] { }));
        Debug.LogWarning("Connection was closed by the server:>" + msg + " Distype:>" + dis);
    }
コード例 #11
0
    /// <summary>
    /// 接收到消息
    /// </summary>
    /// <param name="ms"></param>
    void OnReceivedMessage(MemoryStream ms)
    {
        byte[] message = ms.ToArray();
        //int msglen = message.Length;
        ByteBuffer buffer = new ByteBuffer(message);

        NetworkManager.AddEvent(Protocal.Message, buffer);
        ms.Close();
    }
コード例 #12
0
ファイル: SocketClient.cs プロジェクト: midgithub/sanguo
    /// <summary>
    /// 丢失链接
    /// </summary>
    void OnDisconnected(Protocal protocal, short error, string msg)
    {
        Close();
        ByteBuffer buffer = new ByteBuffer();

        buffer.WriteShort(error);
        buffer.WriteString(msg);
        NetworkManager.AddEvent((int)protocal, new ByteBuffer(buffer.ToBytes()));
        buffer.Close();
    }
コード例 #13
0
 /// <summary>
 /// 丢失链接
 /// </summary>
 void OnDisconnected(string msg)
 {
     Close();   //关掉客户端链接
     if (OnEvent != null)
     {
         LuaByteBuffer buffer = new LuaByteBuffer();
         NetworkManager.AddEvent(OnEvent, Protocal.Disconnect, ref buffer);
     }
     Debug.Log("Connection was closed by the server:>" + msg);
 }
コード例 #14
0
 /// <summary>
 /// 连接上服务器
 /// </summary>
 void OnConnect(IAsyncResult asr)
 {
     try{
         outStream = client.GetStream();
         client.GetStream().BeginRead(byteBuffer, 0, MAX_READ, new AsyncCallback(OnRead), null);
         NetworkManager.AddEvent(Protocal.Connect, new ByteBuffer());
     } catch (Exception e) {
         Close(); Debug.LogError(e.Message);
     }
 }
コード例 #15
0
ファイル: SocketClient.cs プロジェクト: xubingyue/PixelWorld
    /// <summary>
    /// 丢失链接
    /// </summary>
    void OnDisconnected(DisType dis, string msg)
    {
        Close();           //关掉客户端链接
        int protocol = dis == DisType.Exception ? Protocol.Exception : Protocol.Disconnect;

        ByteBuffer buffer = new ByteBuffer();

        buffer.WriteShort((short)protocol);
        NetworkManager.AddEvent(protocol, buffer);
    }
コード例 #16
0
ファイル: SocketClient.cs プロジェクト: daxingyou/Hunter
    /// <summary>
    /// 丢失链接
    /// </summary>
    void OnDisconnected(DisType dis, string msg)
    {
        Close();   //关掉客户端链接
        string protocal = dis == DisType.Exception ?
                          "Exception" : "Disconnect";

        //ByteBuffer buffer = new ByteBuffer();
        //buffer.WriteShort((ushort)protocal);
        NetworkManager.AddEvent(protocal);
        Debug.LogError("Connection was closed by the server:>" + msg + " Distype:>" + dis);
    }
コード例 #17
0
ファイル: SocketClient.cs プロジェクト: Avatarchik/UnityHello
    private void OnDisconnected(DisType dis, string msg)
    {
        //关掉客户端链接
        Close();
        int        protocal = dis == DisType.Exception ? Protocal.Exception : Protocal.Disconnect;
        ByteBuffer buffer   = new ByteBuffer();

        buffer.WriteShort((ushort)protocal);
        NetworkManager.AddEvent(protocal, buffer);
        Debug.LogError("Connection was closed by the server:>" + msg + " Distype:>" + dis);
    }
コード例 #18
0
ファイル: SocketClient.cs プロジェクト: midgithub/sanguo
    /// <summary>
    /// 接收到消息
    /// </summary>
    /// <param name="ms"></param>
    void OnReceivedMessage(MemoryStream ms)
    {
        BinaryReader r = new BinaryReader(ms);

        byte[] message = r.ReadBytes((int)(ms.Length - ms.Position));

        ByteBuffer buffer    = new ByteBuffer(message);
        int        commandId = buffer.ReadShort();

        NetworkManager.AddEvent(commandId, buffer);
    }
コード例 #19
0
 void AddEvent(int protocal, string message)
 {
     if (_networkManagerType == 1)
     {
         NetworkManager.AddEvent(protocal, message);
     }
     else if (_networkManagerType == 2)
     {
         NetworkManager2.AddEvent(protocal, message);
     }
 }
コード例 #20
0
    /// <summary>
    /// 接收到消息
    /// </summary>
    /// <param name="ms"></param>
    void OnReceivedMessage(MemoryStream ms)
    {
        BinaryReader r = new BinaryReader(ms);

        byte[] message = r.ReadBytes((int)(ms.Length - ms.Position));
        //int msglen = message.Length;
        ByteBuffer buffer = new ByteBuffer(message);
        ushort     mainId = buffer.ReadShort();

        NetworkManager.AddEvent(mainId, buffer);
    }
コード例 #21
0
    /// <summary>
    /// 丢失链接
    /// </summary>
    private void OnDisconnected(DisType dis, string msg)
    {
        Close(); //关掉客户端链接
        var protocal = dis == DisType.Exception ? Protocal.Exception : Protocal.Disconnect;

        var buffer = new ByteBuffer();

        buffer.WriteInt(protocal);
        NetworkManager.AddEvent(protocal, string.Empty);
        Util.LogError("Connection was closed by the server:>" + msg + " Distype:>" + dis);
    }
コード例 #22
0
    /// <summary>
    /// 接收到消息
    /// </summary>
    /// <param name="ms"></param>
    void OnReceivedMessage(MemoryStream ms)
    {
        BinaryReader r = new BinaryReader(ms);

        byte[]     message   = r.ReadBytes((int)(ms.Length - ms.Position));
        ByteBuffer buffer    = new ByteBuffer(message);
        int        mainId    = buffer.ReadShort();
        int        pbDataLen = message.Length - 2;

        byte[] pbData = buffer.ReadBytes(pbDataLen);
        NetworkManager.AddEvent(mainId, pbData);
    }
コード例 #23
0
    /// <summary>
    /// 接收到消息
    /// </summary>
    /// <param name="ms"></param>
    void OnReceivedMessage(int msgID, MemoryStream ms)
    {
        BinaryReader r = new BinaryReader(ms);

        byte[]        message = r.ReadBytes((int)(ms.Length - ms.Position));
        LuaByteBuffer buffer  = new LuaByteBuffer(message);

        if (OnMessage != null)
        {
            NetworkManager.AddEvent(OnMessage, msgID, ref buffer);
        }
    }
コード例 #24
0
    /// <summary>
    /// 连接上服务器
    /// </summary>
    void OnConnect(IAsyncResult asr)
    {
        if (!client.Connected)
        {
            OnDisconnected(DisType.Exception, "can't connect to server.");
            return;
        }

        outStream = client.GetStream();
        outStream.BeginRead(byteBuffer, 0, MAX_READ, new AsyncCallback(OnRead), null);
        NetworkManager.AddEvent(Protocal.Connect, new ByteBuffer());
    }
コード例 #25
0
ファイル: SocketClient.cs プロジェクト: xubingyue/PixelWorld
    /// <summary>
    /// 连接上服务器
    /// </summary>
    void ConnectCallback(IAsyncResult asr)
    {
        TcpClient socket = (TcpClient)asr.AsyncState;

        if (socket.Connected == false)
        {
            NetworkManager.AddEvent(Protocol.Refused, new ByteBuffer());
            return;
        }
        outStream = client.GetStream();
        client.GetStream().BeginRead(byteBuffer, 0, MAX_READ, new AsyncCallback(OnRead), null);
        NetworkManager.AddEvent(Protocol.Connect, new ByteBuffer());
    }
コード例 #26
0
    /// <summary>
    /// 接收到消息
    /// </summary>
    /// <param name="ms"></param>
    void OnReceivedMessage(MemoryStream ms)
    {
        BinaryReader r = new BinaryReader(ms);

        byte[] message = r.ReadBytes((int)(ms.Length - ms.Position));
        //int msglen = message.Length;

        ByteBuffer buffer = new ByteBuffer(message);
        int        rid    = buffer.ReadInt();

        Debug.Log("接收到的消息rid为------>" + rid);
        NetworkManager.AddEvent(rid, buffer);
    }
コード例 #27
0
    /// <summary>
    /// 接收到消息
    /// </summary>
    /// <param name="ms"></param>
    void OnReceivedMessage(MemoryStream ms)
    {
        BinaryReader r = new BinaryReader(ms);

        byte[] message = r.ReadBytes((int)(ms.Length - ms.Position));
        //int msglen = message.Length;

        ByteBuffer buffer = new ByteBuffer(message);

        // int mainId = buffer.ReadShort();
        // Debug.Log(string.Format("OnReceivedMessage len {0}", message.Length));
        NetworkManager.AddEvent(Protocal.Message, buffer);
    }
コード例 #28
0
	private void OnDisconnected(DisType dis, string msg)
	{
		this.Close();
		int num = (dis != DisType.Exception) ? 103 : 102;
		ByteBuffer byteBuffer = new ByteBuffer();
		byteBuffer.WriteShort((ushort)num);
		NetworkManager.AddEvent(num, byteBuffer);
		Debug.LogError(string.Concat(new object[]
		{
			"Connection was closed by the server:>",
			msg,
			'Distype:>",
			dis
		}));
コード例 #29
0
ファイル: SocketClient.cs プロジェクト: atom-chen/wudihanghai
    private void OnDisconnected(DisType dis, string msg)
    {
        this.Close();
        int @event = (dis != DisType.Exception) ? 103 : 102;

        NetworkManager.AddEvent(@event, new LuaByteBuffer(Encoding.Default.GetBytes(msg)));
        Debug.LogWarning(string.Concat(new object[]
        {
            "Connection was closed by the server:>",
            msg,
            " Distype:>",
            dis
        }));
    }
コード例 #30
0
ファイル: SocketClient.cs プロジェクト: atom-chen/wudihanghai
 private void OnConnect(IAsyncResult asr)
 {
     if (this.client.Connected)
     {
         this.outStream = this.client.GetStream();
         this.client.GetStream().BeginRead(this.byteBuffer, 0, 8192, new AsyncCallback(this.OnRead), null);
         NetworkManager.AddEvent(101, new LuaByteBuffer(Encoding.Default.GetBytes("true")));
     }
     else
     {
         NetworkManager.AddEvent(101, new LuaByteBuffer(Encoding.Default.GetBytes("false")));
     }
     this.client.EndConnect(asr);
 }