|
|
|
@ -24,6 +24,7 @@ namespace formula_manage.UserClass |
|
|
|
//字典集合:存储IP和Socket的集合
|
|
|
|
public static Dictionary<string, Socket> OnLineList = new Dictionary<string, Socket>(); |
|
|
|
|
|
|
|
DataTable IPdataTable = new DataTable(); //建立缓存
|
|
|
|
//当前时间
|
|
|
|
|
|
|
|
private string CurrentTime |
|
|
|
@ -89,7 +90,9 @@ namespace formula_manage.UserClass |
|
|
|
|
|
|
|
int length = -1; |
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
length = clientSocket.Receive(buffer); |
|
|
|
} |
|
|
|
catch (Exception) |
|
|
|
@ -105,6 +108,7 @@ namespace formula_manage.UserClass |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (length == 0) |
|
|
|
{ |
|
|
|
//客户端下线了
|
|
|
|
@ -112,7 +116,6 @@ namespace formula_manage.UserClass |
|
|
|
string ip = clientSocket.RemoteEndPoint.ToString(); |
|
|
|
UserClass.LogGing.LogGingDATA("IP_Line = " + ip); |
|
|
|
// AddOnLine(ip, false);
|
|
|
|
|
|
|
|
OnLineList.Remove(ip); |
|
|
|
|
|
|
|
break; |
|
|
|
@ -123,7 +126,6 @@ namespace formula_manage.UserClass |
|
|
|
infoR = econding.GetString(buffer, 0, length); |
|
|
|
//ShowMessage(info);
|
|
|
|
string ip = clientSocket.RemoteEndPoint.ToString(); |
|
|
|
Bn_Send(ip, infoR+"return"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -169,34 +171,27 @@ namespace formula_manage.UserClass |
|
|
|
/// <summary>
|
|
|
|
/// 消息发送
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
|
|
public static void Bn_Send(string IP ,string DAT) |
|
|
|
{ |
|
|
|
|
|
|
|
if (OnLineList.ContainsKey(IP)) |
|
|
|
{ |
|
|
|
OnLineList[IP].Send(econding.GetBytes(DAT)); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
/* |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 群发功能
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
/// <param name="e"></param>
|
|
|
|
private void btn_SendAll_Click(object sender, EventArgs e) |
|
|
|
public static void Btn_SendAll(string DAT) |
|
|
|
{ |
|
|
|
foreach (string item in this.lst_Online.Items) |
|
|
|
foreach (string item in OnLineList.Keys.ToArray()) |
|
|
|
{ |
|
|
|
if (OnLineList.ContainsKey(item)) |
|
|
|
{ |
|
|
|
OnLineList[item].Send(econding.GetBytes(this.txt_Send.Text.Trim())); |
|
|
|
OnLineList[item].Send(econding.GetBytes(DAT)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|