private void searchBtn_Click(object sender, EventArgs e) { string searchStr; if (searchTB.ForeColor == Color.LightGray) { searchStr = ""; } else { searchStr = searchTB.Text; } string sex = sexCB.Text; string age = ageCB.Text; bool online = onlineCheckBox.Checked; JObject obj = new JObject(); obj.Add("searchStr", searchStr); obj.Add("sex", sex); obj.Add("age", age); obj.Add("online", online); obj.Add("id", GlobalClass.CurrentUser.Id.ToString()); obj.Add("notids", Util.GetIdInFriends()); string usersStr = HTTPUtil.SendPostRequest(Util.GetHttpUrl() + "/searchusers", obj.ToString()); FillDataGrid(usersStr); }
public void Init() { Tuple <List <int>, List <DateTime>, List <int> > list = UserChatRecordManager.GetUserIdList(GlobalClass.CurrentUser.Id, Ids, contentTB.Text); if (list.Item1.Count > 0) { string ids = string.Join(",", list.Item1); string Users = HTTPUtil.SendGetRequest(Util.GetHttpUrl() + "/getUsersByUserid/" + ids); JArray usersArray = JArray.Parse(Users); userList = new List <User>(); for (int i = 0; i < usersArray.Count; i++) { User user = new User() { Id = int.Parse((string)usersArray[i]["id"]), Name = (string)usersArray[i]["name"], Account = (string)usersArray[i]["account"], Headimage = (string)usersArray[i]["headimage"] }; userList.Add(user); Image image = string.IsNullOrEmpty(user.Headimage) ? Properties.Resources.defalut : Util.GetImageByBase64Str(user.Headimage); imageList.Images.Add(i.ToString(), image); } for (int i = 0; i < userList.Count; i++) { ListViewItem lvi = new ListViewItem(); lvi.ImageIndex = i; //通过与imageList绑定,显示imageList中第i项图标 lvi.Text = userList[i].Name + "(" + userList[i].Account + ")"; lvi.SubItems.Add(list.Item2[i].ToString("yyyy-MM-dd HH:mm:ss")); lvi.SubItems.Add(list.Item3[i].ToString()); this.listView.Items.Add(lvi); } this.listView.Items[0].Selected = true; } }
//初始步骤 public void initialize() { Debug.Log("Gaming initialize"); isGaming = true; life = 1; score = 0; //如果是在线游戏 if (gameStatus == Constant.GAME_ONLINE) { //初始化本地玩家状态对象 playerStatus = new PlayerStatus(playerInfo.id); //获取第一页地图 if (platformInfoQueue.Count <= Constant.MIN_COUNT_OF_PLATFROM_INFO_QUEUE) { HTTPUtil.getPlatformInfo(); } //初始化远程玩家doodle对象 playerNum = team.players.Length; if (playerNum >= 2) { playerStatuses = new PlayerStatus[playerNum - 1]; remoteDoodle = Doodle.create(getTeamPlayerDoodleType()); remoteDoodle.gameObject.name = "RemoteDoodle"; remoteDoodle.isDirvedLocal = false; } StatusWorker.work(); } //初始化本地玩家doodle对象 doodle = Doodle.create( doodleType ); //完成初始化 isInitialized = true; UIManager.INSTANCE.loadPlayerPanel(); }
void SignOutTask() { Debug.Log("Welcome: SignOut"); new Thread(() => { HTTPUtil.signOut(); }).Start(); }
private void OpenChatForm() { if (nf != null) { nf.Close(); } string info = friendsTree.SelectedNode.Text; int startindex = info.IndexOf('('); int endindex = info.IndexOf(')'); string param = info.Substring(startindex + 1, endindex - startindex - 1); string result = HTTPUtil.SendGetRequest(Util.GetHttpUrl() + "/getuserbyaccount/" + param); User DestUser = User.GetUserByStr(result); if (Id_Chat.TryGetValue(DestUser.Id, out Chat chat)) { chat.Activate(); } else { Chat newchat = new Chat(); newchat.DestUser = DestUser; Id_Chat.TryAdd(DestUser.Id, newchat); newchat.Init(); Id_Messages.TryRemove(DestUser.Id, out List <MessageType> list); if (list != null) { newchat.InitChatText(list); } newchat.Show(); } }
private void 添加分组ToolStripMenuItem_Click(object sender, EventArgs e) { AddGroupForm af = new AddGroupForm(); af.ShowDialog(); if (af.IsOk) { if (Group_Users.ContainsKey(af.groupname)) { MessageBox.Show("已存在该分组!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } JObject param = new JObject(); param.Add("id", GlobalClass.CurrentUser.Id); param.Add("groupname", af.groupname); string result = HTTPUtil.SendPostRequest(Util.GetHttpUrl() + "/addgroup", param.ToString()); if (result == "添加成功!") { friendsTree.Nodes.Add(af.groupname); Group_Users.Add(af.groupname, new List <User>()); GlobalClass.Groups.Add(af.groupname); } else { MessageBox.Show(result, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void 除分组ToolStripMenuItem_Click(object sender, EventArgs e) { if (Group_Users.Count == 1) { MessageBox.Show("您只有一个分组!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show("确认删除此分组以及该分组下的好友吗?", "询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { string groupname = friendsTree.SelectedNode.Text; JObject param = new JObject(); param.Add("id", GlobalClass.CurrentUser.Id); param.Add("groupname", groupname); string result = HTTPUtil.SendPostRequest(Util.GetHttpUrl() + "/deletegroup", param.ToString()); if (result == "删除成功!") { friendsTree.Nodes.Remove(friendsTree.SelectedNode); Group_Users.Remove(groupname); } else { MessageBox.Show(result, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void okBtn_Click(object sender, EventArgs e) { if (operationType == 1) //添加好友 { MessageType msg = new MessageType(GlobalClass.CurrentUser.Id, destid, groupComBox.Text, 2); TCPUtil.socketSend.Send(msg.ToJsonBytes()); //发送好友请求 MessageBox.Show("发送成功,请等待对方验证!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (operationType == 2) //被添加好友 { JObject obj = new JObject(); obj.Add("id", GlobalClass.CurrentUser.Id); obj.Add("destid", destid); obj.Add("thisgroup", groupComBox.Text); obj.Add("thatgroup", group); string result = HTTPUtil.SendPostRequest(Util.GetHttpUrl() + "/addfriends", obj.ToString()); if (result == "添加成功!") { MessageBox.Show(result, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); issuccess = true; } else { MessageBox.Show(result, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); issuccess = false; } } Close(); }
void QuitTask() { Debug.Log("Welcome: Quit"); new Thread(() => { HTTPUtil.signOut(); }).Start(); Application.Quit(); }
void CreateTask() { //创建队伍 Debug.Log("ChooseMode Create"); GameManager.INSTANCE.gaming.team = HTTPUtil.createTeam(); //进入新建的队伍信息界面 UIManager.INSTANCE.choosemode.gameObject.SetActive(false); UIManager.INSTANCE.loadTeamStatus(); }
private static void task() { while (true) { HTTPUtil.push(GameManager.INSTANCE.gaming.playerStatus); GameManager.INSTANCE.gaming.playerStatuses = HTTPUtil.pull(); Thread.Sleep(16); } }
void ChooseTask() { Debug.Log("ChooseTask"); //GameManager.INSTANCE.gaming.team.id = dropdown.value;错误的取值方法 //将选择的队伍id传给GameManager.INSTANCE.gaming.team GameManager.INSTANCE.gaming.team.id = int.Parse(dropdown.options.ToArray()[dropdown.value].text); UIManager.INSTANCE.chooseteam.gameObject.SetActive(false); HTTPUtil.joinTeam(); UIManager.INSTANCE.loadTeamStatus(); }
void StartTask() { Debug.Log("TeamStatus: StartTask"); UIManager.INSTANCE.teamstatus.gameObject.SetActive(false); GameManager.INSTANCE.gaming.gameStatus = Constant.GAME_ONLINE; //请求服务器:锁定队伍 HTTPUtil.lockTeam(); UIManager.INSTANCE.loadGaming(); GameManager.INSTANCE.gaming.initialize(); }
private void friendsTree_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { friendsTree.LabelEdit = false; string oldName = e.Node.Text; string newName = e.Label; if (newName == null) //没改 { return; } if (string.IsNullOrEmpty(newName)) { MessageBox.Show("组名不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); e.CancelEdit = true; return; } if (!Util.CheckChar(newName)) { MessageBox.Show("组名不能包含标点符号!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); e.CancelEdit = true; return; } JObject obj = new JObject(); obj.Add("id", GlobalClass.CurrentUser.Id); obj.Add("newname", newName); obj.Add("oldname", oldName); string result = HTTPUtil.SendPostRequest(Util.GetHttpUrl() + "/updategroup", obj.ToString()); if (result == "修改成功!") { List <string> list = Group_Users.Keys.ToList(); for (int i = 0; i < list.Count; i++) { if (list[i] == oldName) { list[i] = newName; break; } } List <List <User> > userList = Group_Users.Values.ToList(); Group_Users.Clear(); for (int k = 0; k < list.Count; k++) { Group_Users.Add(list[k], userList[k]); } } else { MessageBox.Show(result, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Init(List <FriendsReq> list) { if (list.Count == 0) { tip.Visible = true; return; } int[] array = new int[list.Count]; for (int i = 0; i < list.Count; i++) { if (list[i].destid == GlobalClass.CurrentUser.Id) { array[i] = list[i].userid; } else { array[i] = list[i].destid; } } string str = string.Join(",", array); string usersStr = HTTPUtil.SendGetRequest(Util.GetHttpUrl() + "/getUsersByUserid/" + str); JArray usersArray = JArray.Parse(usersStr); for (int k = 0; k < list.Count; k++) { for (int i = 0; i < usersArray.Count; i++) { int id = int.Parse((string)usersArray[i]["id"]); if (array[k] == id) { User destUser = new User() { Id = id, Name = (string)usersArray[i]["name"], Account = (string)usersArray[i]["account"], Sex = char.Parse((string)usersArray[i]["sex"]), Birthday = DateTime.Parse((string)usersArray[i]["birthday"]), Headimage = (string)usersArray[i]["headimage"] }; FriendsReq fr = list[k]; fr.DestUser = destUser; GroupList g = new GroupList(); g.fr = fr; g.Init(); g.Dock = DockStyle.Top; this.Controls.Add(g); break; } } } }
/// <summary> /// Gets the thread. /// </summary> /// <returns>The thread.</returns> /// <param name="board">Boad.</param> /// <param name="threadNumber">Thread number.</param> public static Thread GetThread(string board, int threadNumber) { Thread thread = HTTPUtil.DownloadObject <Thread>(Constants.GetThreadUrl(board, threadNumber)); if (thread != null) { foreach (Post item in thread.Posts) { item.Board = board; } } return(thread); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private java.io.InputStream getInputStream(String paramString, java.util.Map<String, String> paramMap) throws Exception private Stream getInputStream(string paramString, IDictionary <string, string> paramMap) { URL uRL = constructURL(paramString, paramMap); HttpURLConnection httpURLConnection = (HttpURLConnection)uRL.openConnection(); httpURLConnection.ConnectTimeout = 4000; httpURLConnection.ReadTimeout = 30000; if (((!string.ReferenceEquals(this.username, null)) ? 1 : 0) & ((!string.ReferenceEquals(this.password, null)) ? 1 : 0)) { httpURLConnection.setRequestProperty("Authorization", "Basic " + HTTPUtil.encode(this.username + ":" + this.password)); } httpURLConnection.setRequestProperty("Content-Type", "application/json"); return(httpURLConnection.InputStream); }
/// <summary> /// Gets the thread asynchronously. /// </summary> /// <returns>The thread.</returns> /// <param name="board">Boad.</param> /// <param name="threadNumber">Thread number.</param> public static async Task <Thread> GetThreadAsync(string board, int threadNumber) { Thread thread = await HTTPUtil.DownloadObjectAsync <Thread>(Constants.GetThreadUrl(board, threadNumber)); if (thread != null) { foreach (Post item in thread.Posts) { item.Board = board; } } return(thread); }
private void _on_HTTPRequest_request_completed(int result, int response_code, string[] headers, byte[] body) { if (result == (int)HTTPRequest.Result.Success && response_code == 200) { ; } else { connectionLost(); return; } var response = Encoding.UTF8.GetString(body, 0, body.Length); var json = JSON.Parse(response); if (json.Error != Error.Ok) { connectionLost(); return; } var world_infos = HTTPUtil.jsonValue <Godot.Collections.Array>(json.Result, "results"); if (world_infos == null) { connectionLost(); return; } connectionLost(lost: false); foreach (Dictionary record in world_infos) { if (record != null) { remote_finished_entries.Enqueue(generateRemoteWorld(record)); } } var worlds_total = HTTPUtil.jsonInt(json.Result, "count"); game_container.fillStubs(worlds_total); requested_level = Math.Max(requested_level, 2 * (((int)games_scrollbar.RectSize.y) / GameContainer.BUTTON_HEIGHT) + 2); next_page = HTTPUtil.jsonValue <string>(json.Result, "next"); if (next_page != null && requested_level > game_container.GamesCount + world_infos.Count) { http_levels_node.Request(next_page); next_page = null; } }
void Start() { choose.onClick.AddListener(ChooseTask); cancle.onClick.AddListener(CancleTask); dropdown.onValueChanged.AddListener(ChangeText); dropdown.captionText.text = "Team List"; teams = HTTPUtil.listTeam(); foreach (TeamDTO team in teams) { dropdown.options.Add( new Dropdown.OptionData(team.id.ToString()) ); } }
void Update() { //刷新列表 if ((timer -= Time.deltaTime) <= 0F) { timer = 1F; dropdown.options.Clear(); teams = HTTPUtil.listTeam(); foreach (TeamDTO team in teams) { dropdown.options.Add( new Dropdown.OptionData(team.id.ToString()) ); } } }
/// <summary> /// Gets thead root object asynchronously. /// </summary> /// <returns>The thread page.</returns> /// <param name="board">Board.</param> /// <param name="page">Page.</param> public static async Task <ThreadRootObject> GetThreadPageAsync(string board, int page) { ThreadRootObject thread = await HTTPUtil.DownloadObjectAsync <ThreadRootObject>(Constants.GetThreadPageUrl(board, page)); if (thread != null) { foreach (Thread item in thread.Threads) { foreach (Post post in item.Posts) { post.Board = board; } } } return(thread); }
private void loginBtn_Click(object sender, EventArgs e) { string accountStr = account.Text; string pwd = password.Text; if (string.IsNullOrEmpty(accountStr)) { MessageBox.Show("请输入账号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrEmpty(pwd)) { MessageBox.Show("请输入密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string url = Util.GetHttpUrl() + "/login/" + accountStr + "/" + pwd; string result = HTTPUtil.SendGetRequest(url); if (result != "登录失败!") { JObject userObj = JObject.Parse(result); int id = int.Parse(userObj["id"].ToString()); Message msg = new Message(id, 0, "", 0); this.Hide(); User user = User.GetUserByStr(result); GlobalClass.CurrentUser = user; GlobalClass.Groups = Util.GetGroups(user.Friends); MainForm mainForm = new MainForm(); mainForm.Init(); GlobalClass.mf = mainForm; mainForm.Show(); try { TCPUtil.socketSend.Send(msg.ToJsonBytes()); } catch (Exception) { MessageBox.Show("请检查网络!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0); } } else { MessageBox.Show(result, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void Update() { if (temp != GameManager.INSTANCE.gaming.score) { if (GameManager.INSTANCE.gaming.score > GameManager.INSTANCE.gaming.playerInfo.record) { temp = GameManager.INSTANCE.gaming.score; GameManager.INSTANCE.gaming.playerInfo.record = temp; HTTPUtil.updateRecord(); socre.text = string.Format("New Record: {0}", GameManager.INSTANCE.gaming.score); } else { socre.text = string.Format("Score: {0}", GameManager.INSTANCE.gaming.score); } } }
private void OkBtn_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(imageStr)) { JObject obj = new JObject(); obj.Add("id", GlobalClass.CurrentUser.Id); obj.Add("image", imageStr); string result = HTTPUtil.SendPostRequest(Util.GetHttpUrl() + "/updateimage", obj.ToString()); if (result == "修改失败!") { MessageBox.Show(result, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } IsSuccess = true; GlobalClass.CurrentUser.Headimage = imageStr; } Close(); }
void SignUpTask() { Debug.Log("SignUp: SignUp"); string name = nameInput.text; string email = emailInput.text; string bio = bioInput.text; string password = passwordInput.text; Debug.Log(string.Format("{0}\n{1}\n{2}\n{3}\n", name, email, bio, password)); if (HTTPUtil.signUp(name, password, bio, email) == 0) { result.text = string.Format("\"{0}\" succeed", name); } else { result.text = string.Format("\"{0}\" failed", name); } }
void SignInTask() { string name = nameInput.text; string password = passwordInput.text; //Debug.Log (string.Format ("SignIn: SignInTask\n{0}\n{1}", name, password)); string sessionId = HTTPUtil.signIn(name, password); if (sessionId.Length == 32) { result.text = string.Format("\"{0}\" succeed", name); GameManager.INSTANCE.sessionId = sessionId; UIManager.INSTANCE.signIn.gameObject.SetActive(false); GameManager.INSTANCE.gaming.playerInfo = HTTPUtil.getPlayerInfo(); //加载皮肤选择 UIManager.INSTANCE.loadChooseSkin(); } else { result.text = string.Format("\"{0}\" failed", name); } }
private WorldEntry generateRemoteWorld(Dictionary json_item) { WorldEntry world_info = new WorldEntry(); world_info.HasServerInfo = true; world_info.Name = HTTPUtil.jsonValue <string>(json_item, "name"); world_info.Author = HTTPUtil.jsonValue <string>(json_item, "author"); world_info.Description = HTTPUtil.jsonValue <string>(json_item, "description"); var base64_icon = HTTPUtil.jsonValue <string>(json_item, "icon"); world_info.Icon = base64_icon != null && base64_icon.Length > 0 ? GDKnyttAssetManager.loadTexture(decompress(Convert.FromBase64String(base64_icon))) : null; world_info.Link = HTTPUtil.jsonValue <string>(json_item, "link"); world_info.FileSize = HTTPUtil.jsonInt(json_item, "file_size"); world_info.Upvotes = HTTPUtil.jsonInt(json_item, "upvotes"); world_info.Downvotes = HTTPUtil.jsonInt(json_item, "downvotes"); world_info.Downloads = HTTPUtil.jsonInt(json_item, "downloads"); world_info.Complains = HTTPUtil.jsonInt(json_item, "complains"); world_info.Verified = HTTPUtil.jsonBool(json_item, "verified"); world_info.Approved = HTTPUtil.jsonBool(json_item, "approved"); return(world_info); }
private void FRBtn_Click(object sender, EventArgs e) { if (nf != null) { nf.Close(); } Id_Messages.TryRemove(0, out List <MessageType> list); string frStr = HTTPUtil.SendGetRequest(Util.GetHttpUrl() + "/friendsreq/getall/" + GlobalClass.CurrentUser.Id); List <FriendsReq> frList = FriendsReq.GetListByStr(frStr); CheckFriendsReqForm fr = new CheckFriendsReqForm(); fr.Init(frList); fr.ShowDialog(); string result = HTTPUtil.SendGetRequest(Util.GetHttpUrl() + "/getfriendsbyid/" + user.Id); if (result != "获取失败!") { GlobalClass.CurrentUser.Friends = result; GlobalClass.Groups = Util.GetGroups(user.Friends); InitTree(); } }
public void InitTree() { if (string.IsNullOrEmpty(user.Friends)) { return; } friendsTree.Nodes.Clear(); Group_Users.Clear(); JArray array = JArray.Parse(user.Friends); for (int i = 0; i < array.Count; i++) { string groupname = (string)array[i]["name"]; friendsTree.Nodes.Add(groupname); string membersStr = (string)array[i]["members"]; List <User> list = new List <User>(); if (string.IsNullOrEmpty(membersStr)) { Group_Users.Add(groupname, list); continue; } string Users = HTTPUtil.SendGetRequest(Util.GetHttpUrl() + "/getUsersByUserid/" + membersStr); JArray usersArray = JArray.Parse(Users); for (int k = 0; k < usersArray.Count; k++) { User user = new User() { Id = int.Parse((string)usersArray[k]["id"]), Name = (string)usersArray[k]["name"], Account = (string)usersArray[k]["account"], Headimage = (string)usersArray[k]["headimage"] }; friendsTree.Nodes[i].Nodes.Add(user.Name + "(" + user.Account + ")"); list.Add(user); } Group_Users.Add(groupname, list); } }