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


C# PacketWriter.WriteUnicode方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: OnPlayerList

 public static void OnPlayerList(this Session client)
 {
     lock (client.Server.Clients)
     {
         using (PacketWriter writer = new PacketWriter(2))
         {
             writer.Write((byte)RoomMessage.PlayerList);
             writer.Write(client.Server.Clients.Count);
             foreach (Session session in client.Server.Clients.Values)
             {
                 writer.Write(session.ServerInfo == null ? 0 : session.ServerInfo.Port);
                 writer.WriteUnicode(session.Name, 20);
                 writer.WriteUnicode(session.RoomName, 20);
             }
             client.Send(writer.Content);
         }
     }
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:18,代码来源:RoomEvent.cs

示例8: OnChatMessage

        public static void OnChatMessage(this RoomServer roomServer, string name, string toname, string msg)
        {
            using (PacketWriter writer = new PacketWriter(2))
            {
                writer.Write((byte)RoomMessage.OnChat);
                writer.Write((short)0x11);
                writer.WriteUnicode(name + ":" + msg);
                if (string.IsNullOrEmpty(toname))
                {
                    Logger.Debug("send to client");
                    roomServer.SendAllClient(writer.Content, name: name);
                }
            }
            using (PacketWriter writer = new PacketWriter(2))
            {
                writer.Write((byte)RoomMessage.Chat);
                writer.WriteUnicode(name, 20);
                writer.WriteUnicode(toname, 20);
                writer.WriteUnicode(msg, msg.Length + 1);
                if (!string.IsNullOrEmpty(toname))
                {
                    lock (roomServer.Clients)
                    {
                        Session sender = null;
                        if (roomServer.Clients.TryGetValue(name, out sender))
                        {
                            sender.Send(writer.Content, true);
                        }
                        else
                        {
#if DEBUG
							Console.WriteLine("no find "+name);
#endif
                        }
                        if (name != toname)
                        {
                            Session recevicer = null;
                            if (roomServer.Clients.TryGetValue(toname, out recevicer))
                            {
                                recevicer.Send(writer.Content, true);
                            }
                            else
                            {
                                if (sender != null)
                                {
                                    sender.SendError("[err]" + toname + " 不在线。");
                                }
#if DEBUG
								Console.WriteLine("no find "+toname);
#endif
                            }
                        }
                    }
                }
                else
                {
                    roomServer.SendAll(writer.Content, true, true);
                }
            }
        }
开发者ID:247321453,项目名称:YgoServer,代码行数:60,代码来源:RoomEvent.cs

示例9: OnChat

 /// <summary>
 /// 发送聊天消息
 /// </summary>
 public bool OnChat(string msg, bool hidename, string toname = "")
 {
     using (PacketWriter writer = new PacketWriter(2))
     {
         writer.Write((byte)RoomMessage.Chat);
         if (string.IsNullOrEmpty(toname))
         {
             if (hidename)
             {
                 if (random.Next(100) < 10)
                 {
                     writer.WriteUnicode("[匿名]"+ Name, 20);
                 }
                 else {
                     //90%匿名
                     writer.WriteUnicode("[匿名]", 20);
                 }
             }
             else {
                 writer.WriteUnicode(Name, 20);
             }
         }
         else {
             writer.WriteUnicode(Name, 20);
         }
         writer.WriteUnicode(toname, 20);
         writer.WriteUnicode(msg, msg.Length + 1);
         Send(writer.Content);
     }
     return false;
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:34,代码来源:Client.cs

示例10: Login

 /// <summary>
 /// 联网登录
 /// </summary>
 public void Login(string name, string pwd,bool force = false)
 {
     Name = name;
     //Pwd = pwd;
     pwd = Tool.GetMd5(pwd);
     using (PacketWriter writer = new PacketWriter(2))
     {
         writer.Write((byte)RoomMessage.Info);
         writer.WriteUnicode(Name, 20);
         writer.WriteUnicode(pwd, 32);
         writer.Write(force);
         Send(writer.Content);
     }
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:17,代码来源:Client.cs

示例11: SendServerMsg

 public static void SendServerMsg(this Session session, string msg)
 {
     using (PacketWriter writer = new PacketWriter(2))
     {
         writer.Write((byte)RoomMessage.Chat);
         writer.WriteUnicode("", 20);
         writer.WriteUnicode("", 20);
         writer.WriteUnicode(msg, msg.Length + 1);
         session.Send(writer);
     }
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:11,代码来源:RoomEvent.cs

示例12: LobbyError

		public static void LobbyError(this Session session, string message)
		{
			using (PacketWriter join = new PacketWriter(2))
			{
				join.Write((byte)RoomMessage.JoinGame);
				join.Write(0U);
				join.Write((byte)0);
				join.Write((byte)0);
				join.Write(0);
				join.Write(0);
				join.Write(0);
				// C++ padding: 5 bytes + 3 bytes = 8 bytes
				for (int i = 0; i < 3; i++)
					join.Write((byte)0);
				join.Write(0);
				join.Write((byte)0);
				join.Write((byte)0);
				join.Write((short)0);
				session.Send(join, false);
			}

			using (PacketWriter enter = new PacketWriter(2))
			{
				enter.Write((byte)RoomMessage.HsPlayerEnter);
				enter.WriteUnicode("[err]" + message, 20);
				enter.Write((byte)0);
				session.Send(enter);
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:29,代码来源:ClinetEvent.cs

示例13: SendToken

 public void SendToken(string name, string tk)
 {
     using (PacketWriter token = new PacketWriter(2))
     {
         token.Write((byte)RoomMessage.Info);
         token.WriteUnicode(name, 20);
         token.WriteUnicode(tk, 32);
         lock (DuelServers)
         {
             foreach(DuelServer srv in DuelServers)
             {
                 srv.Send(token);
             }
         }
     }
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:16,代码来源:RoomServer.cs

示例14: server_OnRoomClose

 public static void server_OnRoomClose(this RoomServer roomServer, DuelServer server, string name)
 {
     using (PacketWriter writer = new PacketWriter(2))
     {
         writer.Write((byte)RoomMessage.RoomClose);
         writer.Write(server.Port);
         writer.WriteUnicode(name, 20);
         roomServer.SendAll(writer.Content);
     }
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:10,代码来源:RoomEvent.cs

示例15: server_OnRoomCreate

 public static void server_OnRoomCreate(this RoomServer roomServer, DuelServer server, string name, string banlist, string gameinfo)
 {
     using (PacketWriter writer = new PacketWriter(2))
     {
         writer.Write((byte)RoomMessage.RoomCreate);
         writer.Write(server.Port);
         writer.Write(server.NeedAuth);
         writer.WriteUnicode(name, 20);
         writer.WriteUnicode(banlist, 20);
         writer.WriteUnicode(gameinfo, gameinfo.Length + 1);
         //start duel
         writer.Write(false);
         roomServer.SendAll(writer.Content);
     }
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:15,代码来源:RoomEvent.cs


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