当前位置: 首页>>代码示例>>C#>>正文


C# PacketWriter.Write方法代码示例

本文整理汇总了C#中System.IO.PacketWriter.Write方法的典型用法代码示例。如果您正苦于以下问题:C# PacketWriter.Write方法的具体用法?C# PacketWriter.Write怎么用?C# PacketWriter.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.PacketWriter的用法示例。


在下文中一共展示了PacketWriter.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnServerClose

 public static void OnServerClose(this RoomServer roomServer, DuelServer server)
 {
     using (PacketWriter writer = new PacketWriter(2))
     {
         writer.Write((byte)RoomMessage.ServerClose);
         writer.Write(server.Port);
         DuelServer srv = roomServer.GetMinServer();
         lock (srv.AsyncLock)
         {
             srv.Count = 0;
         }
         if (srv != null)
         {
             //特殊处理
             writer.Write(srv.Port);
             writer.Write(srv.NeedAuth);
             //session.ServerInfo = srv;
             lock (roomServer.Clients)
             {
                 foreach (Session client in roomServer.Clients.Values)
                 {
                     if (client.ServerInfo != null && client.ServerInfo.Port == server.Port)
                     {
                         client.ServerInfo = srv;
                         client.Send(writer.Content);
                     }
                 }
             }
         }
                      
     }
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:32,代码来源:RoomEvent.cs

示例2: SendPacket

 /// <summary>
 /// Creates an instance of a packet
 /// </summary>
 /// <param name="id">the Id, or Command that identifies the packet</param>
 /// <param name="name">The name of the packet</param>
 public SendPacket(int id, string name)
 {
     m_Id = id;
     m_Name = name;
     Stream = PacketWriter.CreateInstance(m_Length);
     Stream.Write((byte)id);
     Stream.Write((short)0);
 }
开发者ID:msx752,项目名称:UltimaXNA,代码行数:13,代码来源:SendPacket.cs

示例3: SendRecvPacket

 public SendRecvPacket(int id, string name)
 {
     Id = id;
     Name = name;
     Stream = PacketWriter.CreateInstance(Length);
     Stream.Write(id);
     Stream.Write((short) 0);
 }
开发者ID:TormentedEmu,项目名称:OpenUO,代码行数:8,代码来源:SendRecvPacket.cs

示例4: OnServerInfo

		public static void OnServerInfo(GameServer server){
			ServerConfig Config = server.Config;
			using(PacketWriter writer=new PacketWriter(2)){
				writer.Write((byte)RoomMessage.Info);
				writer.Write(Config.ServerPort);
				writer.Write(Config.isNeedAuth);
				Send(writer.Content);
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:9,代码来源:ServerApi.cs

示例5: HandlePacket

        public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
        {
            var writer = new PacketWriter();
            writer.Write((uint) 0);
            writer.Write((uint) 0);
            writer.Write((uint) 0);
            writer.Write((uint) 0);

            context.SendPacket(0x11, 0x42, 0x0, writer.ToArray());
        }
开发者ID:Zenohate,项目名称:PolarisServer,代码行数:10,代码来源:SimplePackets.cs

示例6: OnRoomEvent

		public static void OnRoomEvent(this GameServer server, StoSMessage msg, RoomInfo info){
			using(PacketWriter writer = new PacketWriter(2)){
				writer.Write((ushort)msg);
				//length
				writer.Write((ushort)1);
				writer.WriteUnicode(info.Name, 20);
				writer.WriteUnicode(info.Pwd, 20);
				writer.Write((byte)info.Rule);
				writer.Write((byte)info.Mode);
				writer.Write(info.IsStart);
				writer.WriteUnicode(info.Lflist, 60);
				writer.Write(info.Warring);
				writer.Write(info.StartLP);
				writer.Write((ushort)info.players.Length);
				for(int i =0; i<info.players.Length;i++){
					writer.WriteUnicode(info.players[i], 20);
				}
				writer.Write((ushort)info.observers.Count);
				for(int i =0; i<info.observers.Count;i++){
					writer.WriteUnicode(info.observers[i], 20);
				}
				//string str = Tool.ToJson(info);
				//byte[] bs = Encoding.Unicode.GetBytes(str);
				//writer.Write(bs);
				writer.Use();
				//Send(server.LocalClient, writer.Content);
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:28,代码来源:RoomHelper.cs

示例7: DoBlockBalance

        private void DoBlockBalance(Socket socket)
        {
            var writer = new PacketWriter();
            writer.WriteStruct(new PacketHeader(0x90, 0x11, 0x2C, 0x0, 0x0));
            writer.Write(new byte[0x68 - 8]);
            writer.Write(PolarisApp.BindAddress.GetAddressBytes());
            writer.Write((UInt16)12205);
            writer.Write(new byte[0x90 - 0x6A]);

            socket.Send(writer.ToArray());
            socket.Close();
        }
开发者ID:Zenohate,项目名称:PolarisServer,代码行数:12,代码来源:QueryServer.cs

示例8: RicePacket

        public RicePacket(ushort id)
        {
            Writer = new PacketWriter(new MemoryStream());
            ID = id;

            Writer.Write(id);
        }
开发者ID:oxykidz,项目名称:RiceEmu,代码行数:7,代码来源:RicePacket.cs

示例9: OnRoomClose

		public static void OnRoomClose(GameRoom room){
            using (PacketWriter writer=new PacketWriter(2)){
				writer.Write((byte)RoomMessage.RoomClose);
				writer.WriteUnicode(room.Config.Name, 20);
				Send(writer.Content);
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:7,代码来源:ServerApi.cs

示例10: OnPlayerLeave

		public static void OnPlayerLeave(GameSession player, GameRoom room){
            if (player.Name == null || player.Name.StartsWith("[AI]")) return;
            using (PacketWriter writer=new PacketWriter(2)){
				writer.Write((byte)RoomMessage.PlayerLeave);
				writer.WriteUnicode(player.Name, 20);
				writer.WriteUnicode(room.Config.Name, 20);
				Send(writer.Content);
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:9,代码来源:ServerApi.cs

示例11: HandlePacket

        public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
        {
            if (context.Character == null)
                return;

            var reader = new PacketReader(data, position, size);
            reader.BaseStream.Seek(0xC, SeekOrigin.Begin);
            var channel = reader.ReadUInt32();
            var message = reader.ReadUtf16(0x9D3F, 0x44);

            if (message.StartsWith(PolarisApp.Config.CommandPrefix))
            {
                var valid = false;

                // Iterate commands
                foreach (var command in PolarisApp.ConsoleSystem.Commands)
                {
                    var full = message.Substring(1); // Strip the command chars
                    var args = full.Split(' ');

                    if (command.Names.Any(name => args[0].ToLower() == name.ToLower()))
                    {
                        command.Run(args, args.Length, full, context);
                        valid = true;
                        Logger.WriteCommand(null, "[CMD] {0} issued command {1}", context.User.Username, full);
                    }

                    if (valid)
                        break;
                }

                if (!valid)
                    Logger.WriteClient(context, "[CMD] {0} - Command not found", message.Split(' ')[0].Trim('\r'));
            }
            else
            {
                Logger.Write("[CHT] <{0}> <{1}>", context.Character.Name, message);

                var writer = new PacketWriter();
                writer.WritePlayerHeader((uint) context.User.PlayerId);
                writer.Write(channel);
                writer.WriteUtf16(message, 0x9D3F, 0x44);

                data = writer.ToArray();

                foreach (var c in Server.Instance.Clients)
                {
                    if (c.Character == null || c.CurrentZone != context.CurrentZone)
                        continue;

                    c.SendPacket(0x07, 0x00, 0x44, data);
                }
            }
        }
开发者ID:Zenohate,项目名称:PolarisServer,代码行数:54,代码来源:ChatHandler.cs

示例12: OnPlayerEnter

		public static void OnPlayerEnter(GameSession player, GameRoom room){
            if (player.Name==null||player.Name.StartsWith("[AI]")) return;
			using(PacketWriter writer=new PacketWriter(2)){
				writer.Write((byte)RoomMessage.PlayerEnter);
				writer.WriteUnicode(player.Name, 20);
				writer.WriteUnicode(room.Config.Name, 20);
				Send(writer.Content);
			}
			string tip = Messages.RandomMessage();
			if(!string.IsNullOrEmpty(tip))
				player.ServerMessage(Messages.RandomMessage());
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:12,代码来源:ServerApi.cs

示例13: OnRoomCreate

		public static void OnRoomCreate(GameRoom room){
			if(room==null||room.Config==null){
				return;
			}
			using(PacketWriter writer=new PacketWriter(2)){
				writer.Write((byte)RoomMessage.RoomCreate);
				writer.WriteUnicode(room.Name, 20);
				writer.WriteUnicode(room.Config.Name, 20);
				writer.WriteUnicode(room.Config.BanList);
				Send(writer.Content);
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:12,代码来源:ServerApi.cs

示例14: OnSendServerInfo

 public static void OnSendServerInfo(this RoomServer roomServer, Session session)
 {
     using (PacketWriter writer = new PacketWriter(2))
     {
         writer.Write((byte)RoomMessage.Info);
         writer.Write(roomServer.GetChatPort());
         DuelServer srv = roomServer.GetMinServer();
         lock (srv.AsyncLock)
         {
             srv.Count++;
         }
         if (srv != null)
         {
             session.ServerInfo = srv;
             writer.Write(srv.Port);
             writer.Write(srv.NeedAuth);
         }
         else
         {
             writer.Write(0);
             writer.Write((byte)0);
         }
         writer.WriteUnicode(session.Token, 32);
         session.Send(writer.Content);
     }
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:26,代码来源:RoomEvent.cs

示例15: Client

        public Client(Server server, SocketClient socket)
        {
            IsClosed = false;
            _server = server;
            Socket = socket;

            socket.DataReceived += HandleDataReceived;
            socket.ConnectionLost += HandleConnectionLost;

            _readBuffer = new byte[1024 * 64];
            _readBufferSize = 0;

            InputArc4 = null;
            OutputArc4 = null;

            var welcome = new PacketWriter();
            welcome.Write((ushort)3);
            welcome.Write((ushort)201);
            welcome.Write((ushort)0);
            welcome.Write((ushort)0);
            SendPacket(0x03, 0x08, 0, welcome.ToArray());
        }
开发者ID:yos-direct,项目名称:PolarisServer,代码行数:22,代码来源:Client.cs


注:本文中的System.IO.PacketWriter.Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。