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


C# PacketReader.ReadUnicode方法代码示例

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


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

示例1: OnRoomCreate

		private static void OnRoomCreate(DuelServer server, PacketReader packet){
			string name = packet.ReadUnicode(20);
			string info = packet.ReadUnicode(20);
			string banlist=packet.ReadUnicode(50);
			GameConfig config=new GameConfig();
            config.RoomString = info;
            config.Parse(info);
			config.Name=name;
			config.BanList=banlist;
            
			Logger.Debug("OnRoomCreate:"+server.Port+","+name+"|"+info);
			lock(server.Rooms){
                server.Rooms[name] = config;
			}
            if (server.Server != null)
            {
                server.Server.server_OnRoomCreate(server, name, banlist, info);
            }
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:19,代码来源:ServerEvent.cs

示例2: OnServerInfo

		private static void OnServerInfo(Client client, PacketReader reader){
			//服务器信息
			Program.Config.ChatPort = reader.ReadInt32();
			Program.Config.DuelPort = reader.ReadInt32();
			Program.Config.NeedAuth = reader.ReadBoolean();
            client.Pwd = reader.ReadUnicode(32);
#if DEBUG
			MessageBox.Show(Program.Config.ChatPort+":"+Program.Config.DuelPort+":"+Program.Config.NeedAuth + ":" + client.Pwd);
#endif
            client.OnLoginOk();
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:11,代码来源:ClientEvent.cs

示例3: OnError

        private static void OnError(Client client, PacketReader reader){
			//错误
			string err = reader.ReadUnicode(256);
         //   int code = reader.ReadByte();
			MessageBox.Show(err);
			//if(!client.IsLogin){
				try{
					client.Close(client.IsLogin);
				}catch{}
			//}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:11,代码来源:ClientEvent.cs

示例4: OnRoomStart

		private static void OnRoomStart(DuelServer server, PacketReader packet){
			string name = packet.ReadUnicode(20);
			Logger.Debug("OnRoomStart:"+server.Port+","+name);
			lock(server.Rooms){
                GameConfig cfg = null;
                if(server.Rooms.TryGetValue(name, out cfg)){
                    cfg.IsStart = true;
				}else{
					Logger.Warn("no start room:"+name+" form "+server.Port);
				}
			}
			if(server.Server!=null)
				server.Server.server_OnRoomStart(server, name);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:14,代码来源:ServerEvent.cs

示例5: OnGameConnect

		private static void OnGameConnect(Session session, PacketReader packet)
		{
			session.IsClient = true;
			string tag = packet.ReadUnicode(20);
			string pwd = Password.GetPwd(tag);
			string name= Password.OnlyName(tag);
			session.Name =name;
			if(!Login(name, pwd)){
				session.LobbyError("Login fail");
				return;
			}
			session.CreateToken(session.Name, Password.GetPwd(tag));
			session.Server.SendToken(session.Name, session.Token);
			if (session.ip != null)
			{
				lock (session.Server.GameCliens)
				{
					if (!session.Server.GameCliens.ContainsKey(session.ip))
					{
						session.Server.GameCliens.Add(session.ip, session);
					}
				}
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:24,代码来源:ClinetEvent.cs

示例6: OnGameChat

		private static void OnGameChat(Session session, PacketReader packet)
		{
			session.CanGameChat = true;
			string msg = packet.ReadUnicode();
			//  Logger.Info(session.Name+":"+msg);
			if (session.Server != null && !string.IsNullOrEmpty(msg))
			{
				session.Server.OnChatMessage(session.Name, "", msg);
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:10,代码来源:ClinetEvent.cs

示例7: Handler

 private static void Handler(PacketReader reader)
 {
    ushort id =  reader.ReadByte();
     if(id == (ushort)RoomMessage.Info)
     {
         string name = reader.ReadUnicode(20);
         string pwd = reader.ReadUnicode(32);
         lock (Infos)
         {
             Infos[name] = pwd;
         }
     }
     reader.Close();
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:14,代码来源:ServerApi.cs

示例8: OnRoomCreate

		private static void OnRoomCreate(Client client, PacketReader reader){
			//房间创建
			int port = reader.ReadInt32();
			bool needauth = reader.ReadBoolean();
			string room = reader.ReadUnicode(20);
			string banlist = reader.ReadUnicode(20);
			string info = reader.ReadUnicode(40);
			GameConfig2 config = new GameConfig2();
			config.Parse(info);
			config.Name = room;
			config.NeedAuth = needauth;
			config.DeulPort = port;
			config.BanList = banlist;
            config.RoomString = info;
            client.ServerRoomCreate(config);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:16,代码来源:ClientEvent.cs

示例9: OnClientChat

		private static void OnClientChat(Client client, PacketReader reader){
			//大厅聊天
			string name = reader.ReadUnicode(20);
			string toname = reader.ReadUnicode(20);
			string msg = reader.ReadUnicode(256);
			client.ServerChat(name, toname, msg);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:7,代码来源:ClientEvent.cs

示例10: OnPlayerLeave

		private static void OnPlayerLeave(Client client, PacketReader reader){
			int port = reader.ReadInt32();
			string name = reader.ReadUnicode(20);
			string room = reader.ReadUnicode(20);
			client.ServerPlayerLeave(name, new RoomInfo(room, port));
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:6,代码来源:ClientEvent.cs

示例11: OnPlayerList

		private static void OnPlayerList(Client client, PacketReader reader){
			int count = reader.ReadInt32();
			List<PlayerInfo> players=new List<PlayerInfo>();
			for(int i=0;i<count;i++){
				int port = reader.ReadInt32();
				string name = reader.ReadUnicode(20);
				string room = reader.ReadUnicode(20);
                RoomInfo r = new RoomInfo(room, port);
                PlayerInfo p = new PlayerInfo(name);
                if (!string.IsNullOrEmpty(room))
                {
                    lock (p.Rooms)
                    {
                        p.Rooms.Add(r);
                    }
                }
                players.Add(p);
			}
			client.ServerPlayerList(players);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:20,代码来源:ClientEvent.cs

示例12: OnRoomList

		private static void OnRoomList(Client client, PacketReader reader){
			int count = reader.ReadInt32();
			List<GameConfig2> configs=new List<GameConfig2>();
			for(int i=0;i<count;i++){
                int port = reader.ReadInt32();
                bool needauth = reader.ReadBoolean();
                string name = reader.ReadUnicode(20);
				string banlist = reader.ReadUnicode(20);
				string info = reader.ReadUnicode(20);
                bool start = reader.ReadBoolean();
                GameConfig2 config =new GameConfig2();
				config.Parse(info);
				config.Name = name;
				config.BanList = banlist;
				config.DeulPort = port;
				config.NeedAuth = needauth;
                config.IsStart = start;
                config.RoomString = info;
				configs.Add(config);
			}
			client.ServerRoomList(configs);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:22,代码来源:ClientEvent.cs

示例13: OnRoomClose

		private static void OnRoomClose(Client client, PacketReader reader){
			int port = reader.ReadInt32();
			string room = reader.ReadUnicode(20);
			client.ServerRoomClose(new RoomInfo(port, room));
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:5,代码来源:ClientEvent.cs

示例14: OnRoomClose

		private static void OnRoomClose(DuelServer server, PacketReader packet){
			string name = packet.ReadUnicode(20);
			Logger.Debug("OnRoomClose:"+server.Port+","+name);
			lock(server.Rooms){
				if(name == null || !server.Rooms.Remove(name)){
					Logger.Warn("no close room:"+name+" form "+server.Port);
				}
			}
			if(server.Server!=null)
				server.Server.server_OnRoomClose(server, name);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:11,代码来源:ServerEvent.cs

示例15: OnInfo

		//登录
		private static void OnInfo(Session session, PacketReader packet)
		{
			string name = packet.ReadUnicode(20);
			string pwd = packet.ReadUnicode(32);//md5
			//登录
			bool force = packet.ReadBoolean();
			if (Login(name, pwd))
			{
				session.Name = name;
				session.IsPause = false;
				//返回聊天端口,对战端口
				if (session.Server != null)
				{
					lock (session.Server.Clients)
					{
						Session old;
						if (session.Server.Clients.TryGetValue(session.Name, out old))
						{
							if (force)
							{
								old.SendError("[err]你的账号在其他地方登录");
								old.Name = "";
								//   old.Close();
							}
							else
							{
								session.IsLogin = false;
								session.IsPause = true;
								session.SendError("[err]已经登录");
								return;
							}
						}
						session.CreateToken(name, pwd);
						session.Server.SendToken(session.Name, session.Token);
						session.IsLogin = true;
						session.Server.Clients[session.Name]=session;
						session.Server.OnSendServerInfo(session);
						session.Server.server_OnPlayerJoin(session.ServerInfo, session.Name, null);
						if (!string.IsNullOrEmpty(session.Server.Tip))
						{
							session.SendServerMsg(session.Server.Tip);
						}
					}
				}
			}
			else {
				session.SendError("[err]认证失败");
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:50,代码来源:ClinetEvent.cs


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