Example #1
0
        public void Send(Cmd4Send cmd)
        {
            ClientSendBuffer.Clear();
            ClientSendBuffer.PutShort(MSG_HEAD);
            byte[] content = cmd.Encode();
            int    len     = content.Length + 2;//+2是cmd的short长度

            ClientSendBuffer.PutInt(len);
            ClientSendBuffer.PutShort(cmd.Cmd);
            ClientSendBuffer.PutBytes(content);
            byte[] bs = ClientSendBuffer.ToArray();

            //Debug.Log("发送长度:"+bs.Length);

            //IoBuffer ib = new IoBuffer(102400);
            //ib.PutBytes(bs);
            //short head = ib.GetShort();
            //int len0 = ib.GetInt();
            //int cmd0 = ib.GetShort();
            //int contentI = ib.GetInt();
            //string contentS = ib.GetString();
            //Debug.Log("head:"+head+" len0:"+len0+" cmd0:"+cmd0+" contentI:"+contentI+" contentS:"+contentS);

            Send(bs);
        }
Example #2
0
    // 发送消息
    public bool VSendMsg(Cmd4Send iSendMessage)
    {
        Stream s = iSendMessage.GetBuff();

        s.Seek(0, SeekOrigin.Begin);

        int len = (int)s.Length;

        byte[] content = new byte[len];
        s.Seek(0, SeekOrigin.Begin);
        s.Read(content, 0, len);
        return(Send(content));
    }
Example #3
0
        public void Send(string sessionID, Cmd4Send cmd)
        {
            Debug.Log("服务端向sessionID:" + sessionID + " 发送 cmd:" + cmd.Cmd);

            if (SessionDic.ContainsKey(sessionID))
            {
                ServerSendBuffer.Clear();
                ServerSendBuffer.PutShort(MSG_HEAD);
                byte[] content = cmd.Encode();
                int    len     = content.Length + 2;//+2是cmd的short长度
                ServerSendBuffer.PutInt(len);
                ServerSendBuffer.PutShort(cmd.Cmd);
                ServerSendBuffer.PutBytes(content);
                byte[] bs = ServerSendBuffer.ToArray();
                AsyncSend(SessionDic[sessionID]._SocketPackMgr._Socket, bs);
            }
        }
Example #4
0
 // 发送消息
 public virtual bool VSendMsg(Cmd4Send iSendMessage)
 {
     return(false);
 }