//发送消息
        public void Send_1_12()
        {
            MessageData_1_11 messageData = new MessageData_1_11();
            BaseMessageData  body        = new BaseMessageData();

            SendMsg(1, 12, body);
        }
        public void SendMsg(int cmd, int scmd, BaseMessageData body)
        {
            MessageData <BaseMessageData> data = new MessageData <BaseMessageData> ();
            HeadMsg head = new HeadMsg();

            head.cmd  = cmd;
            head.scmd = scmd;
            data.head = head;
            data.body = body;
            ByteBuffer _buff = new ByteBuffer();

            byte[] bytes = data.ToBytes();
            _buff.WriteInt32(bytes.Length);
            _buff.WriteBytes(bytes);
            bytes = _buff.ToBytes();
            switch (Main.Self.clientType)
            {
            case ClientType.client:
                Main.Self.client.Send(bytes);
                break;

            case ClientType.server:
                Main.Self.server.Send(bytes);
                break;

            case ClientType.NULL:
                break;

            default:
                break;
            }
        }
示例#3
0
 public static byte[] ToBytes(this BaseMessageData _base)
 {
     return(Serialize(_base));
 }
        //离开服务器
        public void Send_1_2()
        {
            BaseMessageData body = new BaseMessageData();

            SendMsg(1, 2, body);
        }