WriteString() public method

public WriteString ( string v ) : void
v string
return void
コード例 #1
0
 /// <summary>
 /// 发送数据给服务器
 /// </summary>
 public void SendMessage(string data)
 {
     if (IsConnected == false)
     {
         return;
     }
     try
     {
         ByteBuffer buffer = new ByteBuffer();
         buffer.WriteString(data);
         //Debug.Log("SendMessage:" + data);
         clientSocket.Send(WriteMessage(buffer.ToBytes()));
     }
     catch
     {
         IsConnected = false;
         clientSocket.Shutdown(SocketShutdown.Both);
         clientSocket.Close();
     }
 }
コード例 #2
0
    public static void SendJoinMap(string id)
    {
        for (int i = 0; i < clients.Count; i++)
        {
            if (clients[i].client != null && clients[i].id != id)
            {
                ByteBuffer buffer = new ByteBuffer();
                buffer.WriteLong((long)PacketType._JoinMap);
                buffer.WriteString(clients[i].id);
                Send(id, buffer.ToArray());
                buffer.Dispose();

                buffer = new ByteBuffer();
                buffer.WriteLong((long)PacketType._JoinMap);
                buffer.WriteString(id);
                Send(clients[i].id, buffer.ToArray());
                buffer.Dispose();
            }
        }
    }
コード例 #3
0
        /// <summary>
        /// Sends this when you get cards from talon
        /// </summary>
        public static void Send_YouGotCardsFromTalon(long connectionId, string[] cards)
        {
            //New packet
            ByteBuffer buffer = new ByteBuffer();

            //Add packet id
            buffer.WriteLong((long)ServerPacketId.YouGotCardsFromTalon);

            //Add cards number
            buffer.WriteInteger(cards.Length);

            //Add cards
            for (int i = 0; i < cards.Length; i++)
            {
                buffer.WriteString(cards[i]);
            }

            //Send packet
            SendDataTo(connectionId, buffer.ToArray());
        }
コード例 #4
0
        public byte[] Initialize()
        {
            byte[] receiveIV = BitConverter.GetBytes(Application.Random.Next());
            byte[] sendIV    = BitConverter.GetBytes(Application.Random.Next());

            this.Encryptograph = new AesCryptograph(sendIV, unchecked ((short)(0xFFFF - Application.MapleVersion)));
            this.Decryptograph = new AesCryptograph(receiveIV, Application.MapleVersion);

            using (ByteBuffer buffer = new ByteBuffer(16))
            {
                buffer.WriteShort(0x0E);
                buffer.WriteShort(Application.MapleVersion);
                buffer.WriteString(Application.PatchVersion);
                buffer.WriteBytes(receiveIV);
                buffer.WriteBytes(sendIV);
                buffer.WriteByte(8);

                return(buffer.Array);
            }
        }
コード例 #5
0
        /// <summary>
        /// Remove all player reference from memory and closes the connection
        /// </summary>
        /// <param name="id">Player id</param>
        static void CloseConnection(int id)
        {
            ByteBuffer buffer = new ByteBuffer();

            buffer.WriteInt((int)Enums.AllEnums.SCloseConnection);
            buffer.WriteString(Globals.dicPlayers[id].uName);

            HandleClinet.SendToAllBut(id, buffer.ToArray());

            Globals.clients[id].Client.Close();
            Globals.clients[id] = null;
            Console.WriteLine(">> Closing connection from player " + Globals.dicPlayers[id].uName);
            DB.getInstance("", "").UpdatePlayerPlayTime(Globals.dicPlayers[id]);
            try
            {
                Globals.dicPlayers.Remove(id);
            }
            catch (Exception) { }
            //SendDefaultRespose(true, clNo);
        }
コード例 #6
0
    public void search(GameObject obj)
    {
        if (!MainData.instance.user.login())
        {
            LoginEvent.tryToLogin();
            return;
        }
        int type = 0;

        if (obj.name.Equals("ddjy"))
        {
            type = 1;
        }
        else if (obj.name.Equals("zzjy"))
        {
            type = 2;
        }
        else if (obj.name.Equals("ddpj"))
        {
            type = 3;
        }
        else if (obj.name.Equals("ywcjy"))
        {
            type = 4;
        }
        else if (obj.name.Equals("wdct"))
        {
            type = 5;
        }
        else if (obj.name.Equals("wdscj"))
        {
            type = 6;
        }
        ByteBuffer buffer = ByteBuffer.Allocate(1024);

        buffer.skip(4);
        buffer.WriteString("DealSearch");
        buffer.WriteInt(type);
        buffer.WriteLong(MainData.instance.user.id);
        NetUtil.getInstance.SendMessage(buffer);
    }
コード例 #7
0
ファイル: Client.cs プロジェクト: 963148894/Socket
    public void Send(string data)
    {
        if (!IsConnected)
        {
            return;
        }
        try
        {
            ByteBuffer byteBuffer = new ByteBuffer();
            byteBuffer.WriteString(data);

            socket.Send(WriteMessage(byteBuffer.ToBytes()));
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
            IsConnected = false;
            socket.Shutdown(SocketShutdown.Both);
            socket.Close();
        }
    }
コード例 #8
0
ファイル: Login.cs プロジェクト: Visow/Unity_ToLua
        public void OnDBTask(MySqlConnection conn, CustomArgs args)
        {
            string        token   = args.GetParam("token") as string;
            ClientSession session = args.GetParam("session") as ClientSession;

            DBBase.DBStoredProcedCmd cmd = new DBBase.DBStoredProcedCmd("PRO_CHECK_LOGIN", conn);
            cmd.AddParamVChar("token", token, token.Length);
            int bSuc = cmd.Execute();

            if (bSuc == 0)
            {
                string     account = cmd.GetValue(0, "account") as string;
                int        nGold   = (int)cmd.GetValue(0, "gold");
                ByteBuffer buffer  = new ByteBuffer();
                buffer.WriteString(account);
                buffer.WriteInt(nGold);
                UserUtil.Add(session.uid, session);
                SocketUtil.SendMessage(session, Protocal.Login, buffer);
                return;
            }
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: icansmile/UGUITest
        /// <summary>
        /// 客户端连接请求监听
        /// </summary>
        private static void ClientConnectListen()
        {
            while (true)
            {
                //为新的客户端连接创建一个Socket对象
                Socket clientSocket = serverSocket.Accept();
                Console.WriteLine("客户端{0}成功连接", clientSocket.RemoteEndPoint.ToString());

                //记录客户端
                clientSockets.Add(clientSocket);
                Console.Write(clientSockets.Count);

                //向连接的客户端发送连接成功的数据
                ByteBuffer buffer = new ByteBuffer();
                buffer.WriteString("Connected Server");
                clientSocket.Send(WriteMessage(buffer.ToBytes()));
                //每个客户端连接创建一个线程来接受该客户端发送的消息
                Thread thread = new Thread(RecieveMessage);
                thread.Start(clientSocket);
            }
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: icansmile/UGUITest
        /// <summary>
        /// 接收指定客户端Socket的消息
        /// </summary>
        /// <param name="clientSocket"></param>
        private static void RecieveMessage(object clientSocket)
        {
            Console.WriteLine("clientSocket = " + clientSocket);
            Socket mClientSocket = (Socket)clientSocket;

            while (true)
            {
                try
                {
                    int receiveNumber = mClientSocket.Receive(result);
                    Console.WriteLine("接收客户端{0}消息, 长度为{1}", mClientSocket.RemoteEndPoint.ToString(), receiveNumber);
                    ByteBuffer buff = new ByteBuffer(result);
                    //数据长度
                    int len = buff.ReadShort();
                    //数据内容
                    string data = buff.ReadString();
                    Console.WriteLine("数据内容:{0}", data);


                    var e = clientSockets.GetEnumerator();
                    while (e.MoveNext())
                    {
                        var c = e.Current;
                        //向连接的客户端发送连接成功的数据
//						buff.WriteString("Connected Server");
                        ByteBuffer writer = new ByteBuffer();
                        writer.WriteString(data);
                        c.Send(WriteMessage(writer.ToBytes()));
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                    mClientSocket.Shutdown(SocketShutdown.Both);
                    mClientSocket.Close();
                    break;
                }
            }
        }
コード例 #11
0
        public override void Write()
        {
            ByteBuffer whereBuffer = new ByteBuffer();

            whereBuffer.WriteUInt8((byte)Payload.Where.Type);

            switch (Payload.Where.Type)
            {
            case AddressType.IPv4:
                whereBuffer.WriteBytes(Payload.Where.IPv4);
                break;

            case AddressType.IPv6:
                whereBuffer.WriteBytes(Payload.Where.IPv6);
                break;

            case AddressType.NamedSocket:
                whereBuffer.WriteString(Payload.Where.NameSocket);
                break;

            default:
                break;
            }

            Sha256 hash = new Sha256();

            hash.Process(whereBuffer.GetData(), (int)whereBuffer.GetSize());
            hash.Process((uint)Payload.Where.Type);
            hash.Finish(BitConverter.GetBytes(Payload.Port));

            Payload.Signature = RsaCrypt.RSA.SignHash(hash.Digest, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1).Reverse().ToArray();

            _worldPacket.WriteBytes(Payload.Signature, (uint)Payload.Signature.Length);
            _worldPacket.WriteBytes(whereBuffer);
            _worldPacket.WriteUInt16(Payload.Port);
            _worldPacket.WriteUInt32((uint)Serial);
            _worldPacket.WriteUInt8(Con);
            _worldPacket.WriteUInt64(Key);
        }
コード例 #12
0
    public static byte[] Write(PtOutBinary value)
    {
        //创建字节缓存
        ByteBuffer bfs = new ByteBuffer();


        //写入class_name
        bfs.WriteBool(value.has_class_name);
        if (value.has_class_name)
        {
            bfs.WriteString(value.class_name);
        }


        //写入field_count
        bfs.WriteBool(value.has_field_count);
        if (value.has_field_count)
        {
            bfs.WriteInt32(value.field_count);
        }


        //写入rows数组
        bfs.WriteBool(value.has_rows);
        if (value.has_rows)
        {
            int len = value.rows.Count;
            bfs.WriteInt32(len);
            for (int i = 0; i < len; ++i)
            {
                bfs.WriteBytes(PtOutNode.Write(value.rows[i]));
            }
        }



        //返回 字节数组
        return(bfs.source);
    }
コード例 #13
0
        public static byte[] Write(ReplayInfo info)
        {
            using (ByteBuffer buffer = new ByteBuffer())
            {
                buffer.WriteLong(info.OwnerId);
                buffer.WriteString(info.Version);

                int size = info.Frames.Count;
                buffer.WriteInt32(size);
                for (int i = 0; i < size; ++i)
                {
                    int infoCount = info.Frames[i].Count;
                    buffer.WriteInt32(infoCount);
                    for (int j = 0; j < infoCount; ++j)
                    {
                        FrameIdxInfo fInfo = info.Frames[i][j];
                        buffer.WriteBytes(FrameIdxInfo.Write(fInfo));
                    }
                }
                return(ByteBuffer.CompressBytes(buffer.Getbuffer()));
            }
        }
コード例 #14
0
ファイル: SSH2Client.cs プロジェクト: hst-bridge/BBS
        /// <summary>
        /// Requests that the remote computer cancel an existing remote forwarding request.
        /// </summary>
        /// <param name="bindAddress"></param>
        /// <param name="bindPort"></param>
        /// <returns></returns>
        public bool CancelRemoteForwarding(String bindAddress,
                                           int bindPort)
        {
            ByteBuffer baw = new ByteBuffer();

            baw.WriteString(bindAddress);
            baw.WriteInt(bindPort);

            GlobalRequest request = new GlobalRequest("cancel-tcpip-forward",
                                                      baw.ToByteArray());

            if (SendGlobalRequest(request, true))
            {
                forwardingListeners.Remove(bindAddress + ":" + bindPort);
                forwardingDestinations.Remove(bindAddress + ":" + bindPort);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #15
0
        public void TestShiftAvoidance()
        {
            var bb = new ByteBuffer(1024 * 1024 * 2);

            var s           = new string('x', 1024);
            var startingPos = ByteBuffer.StartWritePacket(bb);

            ByteBuffer.WriteString(bb, s);
            ByteBuffer.EndWritePacket(bb, startingPos, 0);
            var startingPos1 = ByteBuffer.StartWritePacket(bb);

            ByteBuffer.WriteUlong(bb, 1);
            ByteBuffer.EndWritePacket(bb, startingPos1, 0);
            var startingPos2 = ByteBuffer.StartWritePacket(bb);

            ByteBuffer.WriteString(bb, s);
            ByteBuffer.EndWritePacket(bb, startingPos2, 0);
            var startingPos3 = ByteBuffer.StartWritePacket(bb);

            ByteBuffer.WriteUlong(bb, 2);
            ByteBuffer.EndWritePacket(bb, startingPos3, 0);
            ByteBuffer.WriteCommit(bb);
            ByteBuffer.TryReadPacket(bb, r => { Assert.AreEqual(s, ByteBuffer.ReadString(r)); }, 0);
            ByteBuffer.TryReadPacket(bb, r => { Assert.AreEqual(1, ByteBuffer.ReadUlong(r)); }, 0);
            ByteBuffer.ReadCommit(bb);
            Assert.AreNotEqual(0, bb.ReadPosition);
            ByteBuffer.TryReadPacket(bb, r => { Assert.AreEqual(s, ByteBuffer.ReadString(r)); }, 0);
            var startingPos4 = ByteBuffer.StartWritePacket(bb);

            ByteBuffer.WriteUlong(bb, 3);
            ByteBuffer.EndWritePacket(bb, startingPos4, 0);
            ByteBuffer.WriteCommit(bb);
            ByteBuffer.TryReadPacket(bb, r => { Assert.AreEqual(2, ByteBuffer.ReadUlong(r)); }, 0);
            Assert.AreNotEqual(0, bb.ReadPosition);
            ByteBuffer.TryReadPacket(bb, r => { Assert.AreEqual(3, ByteBuffer.ReadUlong(r)); }, 0);
            ByteBuffer.ReadCommit(bb);
            Assert.AreEqual(0, bb.ReadPosition);
        }
コード例 #16
0
ファイル: PtOutNode.cs プロジェクト: dudu502/AiFa
    public static byte[] Write(PtOutNode value)
    {
        //创建字节缓存
        ByteBuffer bfs = new ByteBuffer();


        //写入cols数组
        bfs.WriteBool(value.has_cols);
        if (value.has_cols)
        {
            int len = value.cols.Count;
            bfs.WriteInt32(len);
            for (int i = 0; i < len; ++i)
            {
                bfs.WriteString(value.cols[i]);
            }
        }



        //返回 字节数组
        return(bfs.source);
    }
コード例 #17
0
        /// <summary>
        /// Sends this when somebody joins room
        /// </summary>
        public static void Send_OtherPlayerJoinedRoom(long connectionId, Client joinedClient)
        {
            //New packet
            ByteBuffer buffer = new ByteBuffer();

            //Add packet id
            buffer.WriteLong((long)ServerPacketId.OtherPlayerJoinedRoom);

            //Add player id
            buffer.WriteLong(joinedClient.ConnectionId);

            //Add player's slot number
            buffer.WriteInteger(joinedClient.SlotInRoom);

            //Add nickname
            buffer.WriteStringUnicode(joinedClient.UserData.Nickname);

            //Add avatar
            buffer.WriteString(joinedClient.UserData.AvatarFileUrl);

            //Send packet
            SendDataTo(connectionId, buffer.ToArray());
        }
コード例 #18
0
        static int _m_WriteString(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                ByteBuffer gen_to_be_invoked = (ByteBuffer)translator.FastGetCSObj(L, 1);



                {
                    string _v = LuaAPI.lua_tostring(L, 2);

                    gen_to_be_invoked.WriteString(_v);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
コード例 #19
0
        /// <summary>
        /// Sends data about the room
        /// </summary>
        /// <param name="connectionId">Player who gets message if not sending to everybody</param>
        /// <param name="playerIdsInRoom">Ordered player list in room</param>
        /// <param name="maxPlayers">Max connected players</param>
        /// <param name="sendDataToAll">Send to evetybody</param>
        public static void Send_RoomData(long connectionId, RoomInstance room)
        {
            //New packet
            ByteBuffer buffer = new ByteBuffer();

            //Add packet id
            buffer.WriteLong((long)ServerPacketId.RoomData);

            var clients = room.clientsInRoom;

            //Add maxPlayers
            buffer.WriteInteger(room.MaxPlayers);

            //Add players count
            buffer.WriteInteger(room.ConnectedPlayersN);
            //Add players
            foreach (var client in clients)
            {
                if (client == null)
                {
                    continue;
                }

                //Write player's id
                buffer.WriteLong(client.ConnectionId);
                //Write player's slot number
                buffer.WriteInteger(client.SlotInRoom);
                //Write player's nickname
                buffer.WriteStringUnicode(client.UserData.Nickname);
                //Write player's avatar
                buffer.WriteString(client.UserData.AvatarFileUrl);
            }

            //Send packet
            SendDataTo(connectionId, buffer.ToArray());
        }
コード例 #20
0
    public static void SpawnRegisteredPrefab(string slug, Vector3 pos, Quaternion rot)
    {
        ByteBuffer buffer = new ByteBuffer();

        buffer.WriteLong((long)PacketType.NetSpawn);

        //Send Server The 'slug' of the registered prefab you want to spawn...
        buffer.WriteString(slug);

        //Send Server the position you want to spawn the registered prefab at...
        buffer.WriteFloat(pos.x);
        buffer.WriteFloat(pos.y);
        buffer.WriteFloat(pos.z);

        //Send Server The rotation of the object you want to spawn...
        buffer.WriteFloat(rot.x);
        buffer.WriteFloat(rot.y);
        buffer.WriteFloat(rot.z);
        buffer.WriteFloat(rot.w);

        //Finally, Convert ByteBuffer to byte[] and Send to the server then dispose the buffer.
        SendData(buffer.ToArray());
        buffer.Dispose();
    }
コード例 #21
0
ファイル: Packets.cs プロジェクト: TheDireMaster/ClassicBot
 public void Write(ByteBuffer buf)
 {
     buf.WriteByte(Id);
     buf.WriteString(ExtName);
     buf.WriteInt(Version);
 }
コード例 #22
0
ファイル: Schemas.cs プロジェクト: e2wugui/zeze
 public void Encode(ByteBuffer bb)
 {
     bb.WriteString(Name);
     bb.WriteString(KeyName);
     bb.WriteString(ValueName);
 }
コード例 #23
0
 public void ShouldWriteString()
 {
     byteBuffer.WriteString(messageInputString);
     int bufferLength = byteBuffer.Length();
 }
コード例 #24
0
ファイル: Database.cs プロジェクト: DanMagor/WildCardServer
        public static ByteBuffer GetAttackCard(MySqlConnection connection, int cardID)
        {
            //TEMPORARY:
            string          query = "SELECT * from attack_cards WHERE id='" + cardID + "'";
            MySqlCommand    cmd   = new MySqlCommand(query, connection);
            MySqlDataReader reader;
            ByteBuffer      buffer = new ByteBuffer();

            try
            {
                reader = cmd.ExecuteReader();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw;
            }

            //General Parameters
            int    damage = 0, bullets = 0, accuracy = 0;
            string name = "", image = "";

            //Initiative Effect information
            string initiativeName = "", initiativeEffect = "";
            int    initiativeValue = 0, initiativeDuration = 0;

            //Additional Effects Information
            string additionalEffectName = "", additionalEffect = "";
            int    addtionalEffectValue = 0, additionalEffectDuration = 0;



            while (reader.Read())
            {
                damage   = (int)reader["damage"];
                bullets  = (int)reader["bullets"];
                accuracy = (int)reader["accuracy"];
                name     = (string)reader["name"];
                image    = (string)reader["image"];


                initiativeName     = (string)reader["initiativeName"];
                initiativeEffect   = (string)reader["initiativeEffect"];
                initiativeValue    = (int)reader["initiativeValue"];
                initiativeDuration = (int)reader["initiativeDuration"];


                additionalEffectName     = (string)reader["additionalEffectName"];
                additionalEffect         = (string)reader["additionalEffect"];
                addtionalEffectValue     = (int)reader["additionalEffectValue"];
                additionalEffectDuration = (int)reader["additionalEffectDuration"];
            }

            reader.Close();

            Console.WriteLine("Card with ID '{0}' has {1} damage and {2} bullets", cardID, damage, bullets);


            buffer.WriteInteger(damage);
            buffer.WriteInteger(bullets);
            buffer.WriteInteger(accuracy);
            buffer.WriteString(name);
            buffer.WriteString(image);

            buffer.WriteString(initiativeName);
            buffer.WriteString(initiativeEffect);
            buffer.WriteInteger(initiativeValue);
            buffer.WriteInteger(initiativeDuration);

            buffer.WriteString(additionalEffectName);
            buffer.WriteString(additionalEffect);
            buffer.WriteInteger(addtionalEffectValue);
            buffer.WriteInteger(additionalEffectDuration);

            return(buffer);
        }
コード例 #25
0
        public void Encode(ByteBuffer buffer, object value)
        {
            string str = (string)value;

            buffer.WriteString(str);
        }
コード例 #26
0
ファイル: PacketProcessor.cs プロジェクト: valeIT/swtor-emu
        public static void ProcessPacket(byte[] data, AsyncConnection connection)
        {
            AsyncConnectionData acd    = (connection.AsyncState as AsyncConnectionData);
            ByteBuffer          buffer = new ByteBuffer(ByteOrder.LittleEndian, data, 6, data.Length - 6); // 1 opcode 4 len 1 chk

            if (connection.State == 1)
            {
                buffer.ReadInt();
                string rsaBytes = Encoding.UTF8.GetString(buffer.ReadBytes(1024));
                byte[] rsa      = new byte[512];
                for (int i = 0; i < rsaBytes.Length; i += 2)
                {
                    rsa[i / 2] = byte.Parse(rsaBytes.Substring(i, 2), NumberStyles.HexNumber);
                }
                uint   resultSize = 0;
                IntPtr ptr        = TRSADecrypt(rsa, 512, ref resultSize);
                byte[] decrypted  = new byte[resultSize];
                Marshal.Copy(ptr, decrypted, 0, (int)resultSize);
                Console.WriteLine("Decrypted Size = " + resultSize);
                Console.WriteLine(Utility.HexDump(decrypted));

                // set salsa keys
                ByteBuffer packetbuffer = new ByteBuffer(ByteOrder.LittleEndian, decrypted);
                string     username     = packetbuffer.ReadString();
                string     hash         = packetbuffer.ReadString();

                byte[] key1 = packetbuffer.ReadBytes(32);
                byte[] key2 = packetbuffer.ReadBytes(32); // decrypts client
                byte[] iv1  = packetbuffer.ReadBytes(8);
                byte[] iv2  = packetbuffer.ReadBytes(8);  // decrypts client

                connection.CipheredStream.EnableEncryption(key2, iv2, key1, iv1);

                connection.SetState(2); // State 2 = Ready to decrypt
            }
            else
            {
                switch (data.Length)
                {
                case 14:     // discarded client packet
                    break;

                case 45:
                    byte[] response_45 = new byte[]
                    {
                        0x00, 0x48, 0x00, 0x00, 0x00, 0x48, 0xAF, 0xC5, 0x31, 0x67, 0xFF, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x63, 0x61,
                        0x73, 0x74, 0x6C, 0x65, 0x68, 0x69, 0x6C, 0x6C, 0x74, 0x65, 0x73, 0x74, 0x00, 0x09, 0x00, 0x00,
                        0x00, 0x61, 0x66, 0x63, 0x31, 0x62, 0x62, 0x35, 0x61, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x6C, 0x6F,
                        0x67, 0x69, 0x6E, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
                        0x00, 0x00,
                    };
                    connection.SendRegularPacket(response_45);
                    break;

                case 126:     //omega packet
                    ByteBuffer pkt_omega = new ByteBuffer(ByteOrder.LittleEndian);
                    pkt_omega.WriteBytes(new byte[] {
                        0x00, 0x60,                                                    // Length
                        0x00, 0x00, 0x00, 0x60,                                        // Length
                        0x84, 0xD0, 0xF2, 0x90,                                        // PacketID (with client hack)
                        0x04, 0x00, 0x00, 0x00                                         // ObjectCode
                    });
                    pkt_omega.WriteString("swtor-game-lab-1.swtor.com:20063");         // Server Address
                    pkt_omega.WriteString("WIKRQEOYULPBIEHHADRWAAPNVRYGQHMNRXGHBUIV"); // Some key ?

                    Console.WriteLine(Utility.HexDump(pkt_omega.ToArray()));

                    connection.SendRegularPacket(pkt_omega.ToArray());
                    break;

                default:
                    Console.WriteLine("recv packet, size = " + data.Length);
                    Console.WriteLine(Utility.HexDump(data));
                    break;
                }

                /*List<byte[]> packets = acd.Crypter.ProcessServerFromClient(data);
                 *
                 * foreach (byte[] packet in packets)
                 * {
                 *  ByteBuffer pkt = new ByteBuffer(ByteOrder.BigEndian, packet);
                 *  short opcode = pkt.ReadShort();
                 *  int length = pkt.ReadInt();
                 *
                 *  switch (opcode)
                 *  {
                 *      case 45:
                 *          // Client Selecting a Shard Server
                 *          Console.WriteLine(connection.GetHashCode() + " selecting shard.");
                 *          MemoryStream response_45 = new MemoryStream(new byte[]
                 *          {
                 *              0x00, 0x48, 0x0, 0x00, 0x00, 0x48, 0xAF, 0xC5, 0x31, 0x67, 0xFF, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x63, 0x61,
                 *              0x73, 0x74, 0x6C, 0x65, 0x68, 0x69, 0x6C, 0x6C, 0x74, 0x65, 0x73, 0x74, 0x00, 0x09, 0x00, 0x00,
                 *              0x00, 0x61, 0x66, 0x63, 0x31, 0x62, 0x62, 0x35, 0x61, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x6C, 0x6F,
                 *              0x67, 0x69, 0x6E, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
                 *              0x00, 0x00,
                 *          });
                 *          SendPacket(connection, response_45);
                 *          break;
                 *      default:
                 *          Console.WriteLine("PKTRECV Opcode = " + opcode + " Size = " + length);
                 *          Console.WriteLine("Hex Dump = " + Utility.ToHexString(pkt, true));
                 *          Console.WriteLine("String Dump = " + Encoding.UTF8.GetString(pkt.ToArray()));
                 *          break;
                 *  }
                 * }*/
            }
        }
コード例 #27
0
    void send(GameObject container, bool flag)
    {
        if (!MainData.instance.user.login())
        {
            LoginEvent.tryToLogin();
            return;
        }
        if (flag && !MainData.instance.user.recharge.haveMoney(10))
        {
            DialogUtil.tip("您的邮游币不足,无法推送发布。");
            return;
        }
        Transform   trans      = container.transform;
        UIPopupList typeList   = trans.FindChild("type").GetComponent <UIPopupList>();
        string      addressStr = "";

        if (typeList.value.Equals("现货"))
        {
            Transform   address_tran = trans.FindChild("address");
            UIPopupList addressList  = address_tran.GetComponent <UIPopupList>();
            if (addressList.value.Equals("其他"))
            {
                UIInput input = address_tran.FindChild("inputer").GetComponent <UIInput>();
                if (MyUtilTools.stringIsNull(input.value))
                {
                    UILabel label = input.transform.FindChild("tips").GetComponent <UILabel>();
                    DialogUtil.tip(label.text);
                    return;
                }
                addressStr = "1," + input.value;
            }
            else
            {
                addressStr = "0," + addressList.value;
            }
        }
        else
        {
            Transform   wjs_tran = trans.FindChild("wjs-select");
            UIPopupList wjsList  = wjs_tran.GetComponent <UIPopupList>();
            if (wjsList.value.Equals("其他文交所"))
            {
                UIInput input = wjs_tran.FindChild("inputer").GetComponent <UIInput>();
                if (MyUtilTools.stringIsNull(input.value))
                {
                    UILabel label = input.transform.FindChild("tips").GetComponent <UILabel>();
                    DialogUtil.tip(label.text);
                    return;
                }
                addressStr = "1," + input.value;
            }
            else
            {
                addressStr = "0," + wjsList.value;
            }
        }
        UIInput input_name = trans.FindChild("name").GetComponent <UIInput>();
        string  name       = input_name.value;

        if (MyUtilTools.stringIsNull(name))
        {
            UILabel label = input_name.transform.FindChild("tips").GetComponent <UILabel>();
            DialogUtil.tip(label.text);
            return;
        }
        UIInput input_num = trans.FindChild("num").GetComponent <UIInput>();
        string  num       = input_num.value;

        if (MyUtilTools.stringIsNull(num))
        {
            UILabel label = input_num.transform.FindChild("tips").GetComponent <UILabel>();
            DialogUtil.tip(label.text);
            return;
        }
        UIInput input_price = trans.FindChild("price").GetComponent <UIInput>();
        string  price       = input_price.value;

        if (MyUtilTools.stringIsNull(price))
        {
            UILabel label = input_price.transform.FindChild("tips").GetComponent <UILabel>();
            DialogUtil.tip(label.text);
            return;
        }
        UIPopupList danweiList  = trans.FindChild("danwei").GetComponent <UIPopupList>();
        Transform   time_trans  = trans.FindChild("time");
        UIInput     year        = time_trans.FindChild("year").GetComponent <UIInput>();
        UIInput     month       = time_trans.FindChild("month").GetComponent <UIInput>();
        UIInput     day         = time_trans.FindChild("day").GetComponent <UIInput>();
        UIInput     hour        = time_trans.FindChild("hour").GetComponent <UIInput>();
        UIInput     minute      = time_trans.FindChild("minute").GetComponent <UIInput>();
        string      time        = year.value + "-" + month.value + "-" + day.value + " " + hour.value + ":" + minute.value + ":00";
        UIInput     input_other = trans.FindChild("other").GetComponent <UIInput>();
        string      other       = input_other.value;
        UIToggle    toggle      = trans.FindChild("flag").GetComponent <UIToggle>();
        ByteBuffer  buffer      = ByteBuffer.Allocate(1024);

        buffer.skip(4);
        buffer.WriteString("BuyDeploy");
        buffer.WriteByte((byte)(flag ? 1 : 0));
        buffer.WriteLong(MainData.instance.user.id);
        buffer.WriteByte((byte)(typeList.value.Equals("入库") ? 0 : 1));
        buffer.WriteString(addressStr);
        buffer.WriteString(name);
        buffer.WriteInt(int.Parse(num));
        buffer.WriteString(danweiList.value);
        buffer.WriteString(price);
        buffer.WriteString(time);
        buffer.WriteString(other);
        buffer.WriteByte((byte)(toggle.value ? 1 : 0));
        NetUtil.getInstance.SendMessage(buffer);
    }
コード例 #28
0
ファイル: Packets.cs プロジェクト: TheDireMaster/ClassicBot
 public void Write(ByteBuffer buf)
 {
     buf.WriteByte(Id);
     buf.WriteString(AppName);
     buf.WriteShort(ExtensionCount);
 }
コード例 #29
0
ファイル: Packets.cs プロジェクト: TheDireMaster/ClassicBot
 public void Write(ByteBuffer buf)
 {
     buf.WriteByte(Id);
     buf.WriteString(Reason);
 }
コード例 #30
0
ファイル: Packets.cs プロジェクト: TheDireMaster/ClassicBot
 public void Write(ByteBuffer buf)
 {
     buf.WriteByte(Id);
     buf.WriteByte((byte)PlayerId);
     buf.WriteString(Text);
 }