日期:2014-05-20 浏览次数:21093 次
foreach (ClientService item in clietn) { if (item.mysock.GetHashCode() == model.TcpClientHashCode) { item.SendMessage(loginState); if (loginState == "2001") { foreach (OnlineModel onLineItem in onlineList) { if (onLineItem.TcpClientHashCode != model.TcpClientHashCode) { string userId = onLineItem.UserId.ToString(); while (true) { if (userId.Length == 4) { break; } userId = userId.Insert(0, "0"); } string userName = onLineItem.UserName; int len = userName.Length; while (true) { if (userName.Length == len) { break; } //userName = userName.Insert(len, " "); userName = userName.PadRight(len); } string gender = onLineItem.Gender.ToString(); string message = userId + userName + gender + "0"; string length = message.Length.ToString(); while (true) { if (length.Length == 4) { break; } length = length.Insert(0, "0"); } item.SendMessage(length + message); } } } break; } } #endregion #region 通知其他用户上线信息 if (loginState == "2001")//通知其他用户 { foreach (OnlineModel item in onlineList) { foreach (ClientService clientItem in clietn) { if (item.TcpClientHashCode == clientItem.mysock.GetHashCode() && item.TcpClientHashCode != loginUse.TcpClientHashCode) { string userId = loginUse.UserId.ToString(); while (true) { if (userId.Length == 4) { break; } userId = userId.Insert(0, "0"); } string userName = loginUse.UserName; int len = userName.Length; while (true) { if (userName.Length == len) { break; } //userName = userName.Insert(len, " "); userName = userName.PadRight(len); } string gender = loginUse.Gender.ToString(); string message = userId + userName + gender + "0"; string length = message.Length.ToString(); while (true) { if (length.Length == 4) { break; } length = length.Insert(0, "0"); } clientItem.SendMessage(length + message); } } } } #endregion