Ejemplo n.º 1
0
    public bool Send(ProtocolBase protocol, MsgDistribution.Delegate cb)
    {
        string cbName = protocol.GetName();

        Debug.Log(cbName);
        return(Send(protocol, cbName, cb));
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 发送数据给服务器
    /// </summary>
    public void SendMessage(string data, string cbName, MsgDistribution.Delegate cb)
    {
        ByteBuffer buffer = new ByteBuffer();

        buffer.WriteString(data);
        byte[] msg = WriteMessage(buffer.ToBytes());
        SendMessage(msg, cbName, cb);
    }
Ejemplo n.º 3
0
 public bool Send(ProtocolBase protocolBase, string cbName, MsgDistribution.Delegate cb)
 {
     if (_status != Status.Connected)
     {
         return(false);
     }
     msgDist.AddOnceListener(cbName, cb);
     return(Send(protocolBase));
 }
Ejemplo n.º 4
0
 public bool Send(ProtocolBase protocol, MsgDistribution.Delegate cb, string name)
 {
     if (status != Status.Connected)
     {
         return(false);
     }
     msgDistribution.AddOnceListener(name, cb);
     return(Send(protocol));
 }
Ejemplo n.º 5
0
 public bool Send(GameMessage message, Protocol msgType, MsgDistribution.Delegate cb)
 {
     if (status != Status.Connected)
     {
         return(false);
     }
     msgDist.AddOnceListener(msgType, cb);
     return(Send(message));
 }
Ejemplo n.º 6
0
 // 发送消息的同时绑定回调函数,并指定key名
 public bool Send(string name, string body, string cbName, MsgDistribution.Delegate cb)
 {
     if (!Send(name, body))
     {
         return(false);
     }
     msgDist.AddOnceListener(cbName, cb);
     return(true);
 }
Ejemplo n.º 7
0
 public bool Send(ProtocolBase protocol, string cbName, MsgDistribution.Delegate cb)   //消息监听,可指定协议
 {
     if (status != Status.connected)
     {
         return(false);
     }
     msgDist.AddOnceListener(cbName, cb);
     return(Send(protocol));
 }
        bool Send(ProtocolBase protocol, string cbName, MsgDistribution.Delegate cb)
        {
            bool ret = Send(protocol);

            if (ret)
            {
                msgDist.AddOnceListener(cbName, cb);
            }
            return(ret);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 发送数据
 /// </summary>
 /// <param name="data"></param>
 public void SendMessage(byte[] data, string cbName, MsgDistribution.Delegate cb)
 {
     if (status == Status.None)
     {
         return;
     }
     try
     {
         msgDist.AddOnceListener(cbName, cb);
         socket.Send(data);
     }
     catch
     {
         msgDist.DelOnceListener(cbName, cb);
         status = Status.None;
         socket.Shutdown(SocketShutdown.Both);
         socket.Close();
     }
 }
Ejemplo n.º 10
0
    public bool Send(ProtocolBase protocol, MsgDistribution.Delegate cb)
    {
        string name = protocol.GetName();

        return(Send(protocol, cb, name));
    }
Ejemplo n.º 11
0
    public bool Send(GameMessage message, MsgDistribution.Delegate cb)
    {
        Protocol msgType = (Protocol)message.type[0];

        return(Send(message, msgType, cb));
    }
 public bool Send(ProtocolBase protocol, string cbName, MsgDistribution.Delegate cb)
 {
     msgDist.AddOnceListener(cbName, cb);
     return(Send(protocol));
 }
Ejemplo n.º 13
0
        // 发送消息的同时绑定回调函数,使用Msg+name作为key名
        public bool Send(string name, string body, MsgDistribution.Delegate cb)
        {
            string cbName = "Msg" + name;

            return(Send(name, body, cbName, cb));
        }
Ejemplo n.º 14
0
    public bool Send(ProtocolBase protocol, MsgDistribution.Delegate cb)     //消息监听
    {
        string cbName = protocol.GetName();

        return(Send(protocol, cbName, cb));
    }
Ejemplo n.º 15
0
 public bool Send(string protoName, MsgDistribution.Delegate cb)
 {
     return(Send(new ProtocolBytes(protoName), cb));
 }