Example #1
0
		public UserForm(bool needuser,bool shortpwd)
		{
			InitializeComponent();
			this.NeedUser=needuser;
			this.ShortPwd = shortpwd;
			m_dir=User.DIR;
			loadUsers();
			int i = 0;
			for(i=1;i<99;i++){
				string val = ConfigManager.readString("server"+i.ToString("00"));
				if(string.IsNullOrEmpty(val))
					break;
				ServerInfo s = new ServerInfo(val);
				if(s.isOk){
					Servers.Add(s.Name, s);
				}
			}
			string last = ConfigManager.readString("server");
			i = 0;
			int index = 0;
			foreach(string str in Servers.Keys){
				if(last == str){
					index = 0;
				}
				i++;
				cb_server.Items.Add(str);
			}
			if(cb_server.Items.Count>0){
				cb_server.SelectedIndex = index;
			}
		}
Example #2
0
		public void Connect(ServerInfo info, User user){
			if(client!=null){
				client.Close();
			}
			client = new AsyncClient();
			try{
				client.Connect(info.Host, info.Port);
				using(GameServerPacket login = new GameServerPacket()){
					login.WriteUnicode(user.Name, 20);
					login.WriteUnicode(user.Password, 32);
					login.Use();
					client.BeginSend(login.Content);
				}
			}catch(Exception){
				
			}
		}