Ejemplo n.º 1
0
		public LoginForm()
		{
			Client = new Client();
			m_main = new MainForm(this, Client);
            Client.SetForm(m_main);
            InitializeComponent();
            Client.OnLoginSuccess += delegate {
				BeginInvoke(new Action(()=>{
                    if (chb_record.Checked)
                    {
                        string pwd = tb_password.Text;
                        if (!string.IsNullOrEmpty(pwd))
                        {
                            pwd = Tool.Encrypt(pwd, USER_NAME, KEY);
                            ConfigManager.Save(PWD, pwd);
                        }
                    }
                    else
                    {
                        tb_password.Text = "";
                    }
                    ConfigManager.Save("savepwd", ""+chb_record.Checked);
                   
                    this.Hide();                    
                    m_main.Show();
				                       })
				           );
				
			};
			this.Icon = res.favicon;
		}
Ejemplo n.º 2
0
 public MainForm(Form parentForm,Client client)
 {
     m_parentForm = parentForm;
     Client = client;
     InitializeComponent();
     this.oldTitle = this.Text;
     this.Icon = res.favicon;
     m_create = new CreateRoomForm(Client);
     panel_rooms.SetClient(Client);
 }
Ejemplo n.º 3
0
 private static void OnServerStop(Client client, PacketReader reader)
 {
     MessageBox.Show("服务器关闭");
     try
     {
         client.Close(true);
     }
     catch { }
     client.ServerStop();
 }
Ejemplo n.º 4
0
		public static void Handler(Client client, List<PacketReader> packets){
			if(packets.Count==0) return;
			
			foreach(PacketReader packet in packets){
				//			Parse(player, packet);
				ushort id = packet.ReadByte();
				EventHandler.Do(id, client, packet);
				packet.Close();
			}
		}
Ejemplo n.º 5
0
		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();
		}
Ejemplo n.º 6
0
        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{}
			//}
		}
Ejemplo n.º 7
0
		public CreateRoomForm(Client client)
		{
			InitializeComponent();
			this.client=client;
			cb_banlist.SelectedIndex=0;
			cb_draw.SelectedIndex=0;
			cb_hand.SelectedIndex=4;
			cb_lp.SelectedIndex=1;
			cb_mode.SelectedIndex=0;
			cb_rule.SelectedIndex=2;
			cb_timeout.SelectedIndex=2;
			chk_sp1.Checked=false;
			chk_sp2.Checked=false;
			chk_sp3.Checked=false;
			tb_name.Text="";
			tb_password.Text="";
		}
Ejemplo n.º 8
0
		public void SetClient(Client client){
			this.client=client;
		}
Ejemplo n.º 9
0
		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);
		}
Ejemplo n.º 10
0
		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);
		}
Ejemplo n.º 11
0
		private static void OnServerClose(Client client, PacketReader reader){
			int port = reader.ReadInt32();
			int nport=reader.ReadInt32();
			Program.Config.DuelPort = nport;
			Program.Config.NeedAuth = reader.ReadBoolean();
			client.ServerClose(port);
		}
Ejemplo n.º 12
0
		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));
		}
Ejemplo n.º 13
0
		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);
		}
Ejemplo n.º 14
0
		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);
		}
Ejemplo n.º 15
0
		private static void OnRoomClose(Client client, PacketReader reader){
			int port = reader.ReadInt32();
			string room = reader.ReadUnicode(20);
			client.ServerRoomClose(new RoomInfo(port, room));
		}