コード例 #1
0
        public static void SendOtherPlayerCharacterListRequest(int index)
        {
            PacketBuffer buffer = new PacketBuffer();

            try
            {
                buffer.Write(Outbound.OtherPlayerCharacterListRequest);

                List <Client> clientList = ServerTCP.FetchOtherClients(index);

                buffer.Write(clientList.Count);

                if (clientList.Count > 0)
                {
                    foreach (Client client in clientList)
                    {
                        buffer.Write(client.properties.Username);
                        buffer.Write(client.properties.Position.X);
                        buffer.Write(client.properties.Position.Y);
                        buffer.Write(client.properties.ID);
                    }
                }
                ServerTCP.SendDataTo(index, buffer.ToArray());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                buffer.Dispose();
            }
        }
コード例 #2
0
        public static void Compose(Outbound packetIndex, int clientIndex)
        {
            Console.WriteLine(string.Format("[ServerOutput] {0}", packetIndex));

            PacketBuffer buffer = new PacketBuffer();

            try
            {
                buffer.Write(packetIndex);
                ServerTCP.SendDataTo(clientIndex, buffer.ToArray());
            }
            catch (Exception e) { Console.WriteLine(e.Message); }
            finally { buffer.Dispose(); }
        }