private static CliReq CreateCliReq(ClientMsgType methodId, int userId = 1, ModuleId moduleId = ModuleId.Game) { return(new CliReq { UserId = userId, ModuleId = moduleId, MethodId = methodId, }); }
MsgPair dispatch(string msg, Fleck.IWebSocketConnection clientSock) { int separateIndex = msg.IndexOf("\r\n"); if (separateIndex != -1) { string msgHead = msg.Substring(0, separateIndex); int index = msgIndex[msgHead]; ClientMsgType msgType = (ClientMsgType)index; GlobalMessage globalMsg; if (msgType.Equals(ClientMsgType.LOGIN)) { globalMsg = GlobalMessage.LOGIN; } else if (msgType.Equals(ClientMsgType.LOGOUT)) { globalMsg = GlobalMessage.LOGOUT; } else if (msgType.Equals(ClientMsgType.KEEPALIVEACK)) { globalMsg = GlobalMessage.KEEPALIVEACK; } else { globalMsg = GlobalMessage.DATA; } clientPublishMessage(msg, clientSock, globalMsg); string newMsg = ClientMsgDelegate[index](msg, clientSock); if (newMsg == null) { return(null); } byte[] buffer = addHead(newMsg); MsgPair msgPair = new MsgPair(buffer, globalMsg); return(msgPair); } else { return(null); } }
/// <summary> /// When Other clients Update their status/Public Message, NewsFeed or Buddy news textbox will be added that news /// </summary> /// <param name="info"></param> /// <param name="sts"></param> void Client_NewMStatus(ClientInfo info, string sts, ClientMsgType type) { if (richTxtNewsFeed.InvokeRequired) { richTxtNewsFeed.BeginInvoke(new ServerStatus(Client_NewMStatus), new object[3] { info, sts, type }); } else { Font font1 = new Font(richTxtNewsFeed.Font, FontStyle.Bold); richTxtNewsFeed.SelectionFont = font1; richTxtNewsFeed.SelectionColor = Color.Red; if (info.Name != Program.app.myInfo.Name) { richTxtNewsFeed.SelectedText = Environment.NewLine + info.Name + ":"; } else { richTxtNewsFeed.SelectedText = Environment.NewLine + "You" + ":"; } if (type == ClientMsgType.Status) { Font font2 = new Font(richTxtNewsFeed.Font, FontStyle.Italic); richTxtNewsFeed.SelectionFont = font2; richTxtNewsFeed.SelectionColor = Color.DimGray; richTxtNewsFeed.SelectedText = " Updated status at " + DateTime.Now.ToString("HH:mm:ss"); Font font3 = new Font(richTxtNewsFeed.Font, FontStyle.Regular); richTxtNewsFeed.SelectionFont = font3; richTxtNewsFeed.SelectionColor = Color.Black; richTxtNewsFeed.SelectedText = Environment.NewLine + sts + Environment.NewLine; } else if (type == ClientMsgType.Join) { Font font2 = new Font(richTxtNewsFeed.Font, FontStyle.Italic); richTxtNewsFeed.SelectionFont = font2; richTxtNewsFeed.SelectionColor = Color.DimGray; richTxtNewsFeed.SelectedText = " Joined at " + DateTime.Now.ToString("HH:mm:ss"); Font font3 = new Font(richTxtNewsFeed.Font, FontStyle.Regular); richTxtNewsFeed.SelectionFont = font3; richTxtNewsFeed.SelectionColor = Color.Black; richTxtNewsFeed.SelectedText = Environment.NewLine + Environment.NewLine; } else if (type == ClientMsgType.Disconnect) { Font font2 = new Font(richTxtNewsFeed.Font, FontStyle.Italic); richTxtNewsFeed.SelectionFont = font2; richTxtNewsFeed.SelectionColor = Color.DimGray; richTxtNewsFeed.SelectedText = " Leaved at " + DateTime.Now.ToString("HH:mm:ss"); Font font3 = new Font(richTxtNewsFeed.Font, FontStyle.Regular); richTxtNewsFeed.SelectionFont = font3; richTxtNewsFeed.SelectionColor = Color.Black; richTxtNewsFeed.SelectedText = Environment.NewLine + Environment.NewLine; } if (info.ClientID != Program.app.myInfo.ClientID && this.Width == originalHight) { Font font2 = new Font(richTxtNewsFeed.Font, FontStyle.Italic); richTxtNewsFeed.SelectionFont = font2; richTxtNewsFeed.SelectionColor = Color.DimGray; StatusNumber++; btnNewsFeed.Font = new Font(btnNewsFeed.Font, FontStyle.Bold); btnNewsFeed.BackColor = Color.Yellow; btnNewsFeed.Text = "NewsFeed(" + StatusNumber + ")"; } } }