static public void HeartBeat() { ArrayList arrOnlineUsers = new ArrayList(); lock (Data.Data.ArrOnlineUsers) { for (int i = 0; i < Data.Data.ArrOnlineUsers.Count; i++) { arrOnlineUsers.Add(Data.Data.ArrOnlineUsers[i]); } } ArrayList arrTemp = new ArrayList(); for (int i = 0; i < arrOnlineUsers.Count; i++) { Model.DataPackage package = new Model.DataPackage(); OnlineUserProperties user = (OnlineUserProperties)arrOnlineUsers[i]; package.User_IP = user.Ip; short type = 0; package.Data = BitConverter.GetBytes(type); Newtalking_DAL_Server.Sender sender = new Newtalking_DAL_Server.Sender(package); if (sender.SendMessage(package)) arrTemp.Add((IPAddress)Data.Data.ArrOnlineUsers[i]); } lock (Data.Data.ArrOnlineUsers) { Data.Data.ArrOnlineUsers = arrTemp; } }
public bool Response() { SQLService sql = new SQLService(); ArrayList arrMsg = sql.SelOverMessages(rr.User_id); Sender sender = new Sender(data.Client); foreach (object obj in arrMsg) { MessageData msg = (MessageData)obj; MessageDataConvert converter = new MessageDataConvert(); byte[] dataSend = converter.ConvertToBytes(msg); DataPackage dpk = new DataPackage(); dpk.Data = dataSend; dpk.Client = data.Client; if (!sender.SendMessage(dpk)) return false; } //结束标识 DataPackage endDpk = new DataPackage(); endDpk.Data = BitConverter.GetBytes(0); endDpk.Client = data.Client; sender.SendMessage(endDpk); return true; }
public bool Respect() { DataPackage data = new DataPackage(); data.Client = onlineUser.Client; data.Data = convert.ConvertToBytes(isLogined, loginData.Uid); Sender sender = new Sender(onlineUser.Client); //[未升级] 发送所有消息 //ArrayList arrTemp = new ArrayList(); //lock (Data.Data.ArrSendingMessages) //{ // ArrayList arrNew = Data.Data.ArrSendingMessages; // Data.Data.ArrSendingMessages.Clear(); // for (int i = 0; i < arrNew.Count; i++) // { // MessageData msg = (MessageData)arrNew[i]; // if (msg.Receiver_id == data.User_id) // arrTemp.Add(msg); // else // Data.Data.ArrSendingMessages.Add(msg); // } //} //for (int i = 0; i < arrTemp.Count; i++) //{ // MessageData msg = (MessageData)arrTemp[i]; // Newtalking_DAL_Data.MessageDataConvert convert = new Newtalking_DAL_Data.MessageDataConvert(); // Message msgSend = new Message(convert.ConvertToBytes(msg)); // msgSend.Send(); //}) return sender.SendMessage(data); }
public void Send() { lock (Data.Data.ArrOnlineUsers) { bool isFoundOnline = false; for (int i = 0; i < Data.Data.ArrOnlineUsers.Count; i++) { Data.OnlineUserProperties user = (Data.OnlineUserProperties)Data.Data.ArrOnlineUsers[i]; if (msgData.Receiver_id == user.User_id) { isFoundOnline = true; DataPackage dataPacksge = new DataPackage(); dataPacksge.User_IP = user.Ip; Sender sender = new Sender(dataPacksge); if (sender.SendMessage(dataPacksge)) return; else { lock (Data.Data.ArrSendingMessages) { Data.Data.ArrSendingMessages.Add(msgData); } } } } if (!isFoundOnline) lock (Data.Data.ArrSendingMessages) { Data.Data.ArrSendingMessages.Add(msgData); } } }
public void Respect() { DataPackage data = new DataPackage(); data.User_IP = onlineUser.Ip; data.Data = convert.ConvertToSend(isLogined); Sender sender = new Sender(data); sender.SendMessage(data); }
public void Respect() { DataPackage data = new DataPackage(); data.Client = onlineUser.Client; data.Data = convert.ConvertToBytes(isLogined, loginData.Uid); Sender sender = new Sender(onlineUser.Client); sender.SendMessage(data); }
public void Send() { ArrayList arrOnlineUsers = new ArrayList(); lock (Data.Data.ArrOnlineUsers) { for (int i = 0; i < Data.Data.ArrOnlineUsers.Count; i++) arrOnlineUsers.Add(Data.Data.ArrOnlineUsers[i]); } bool isFoundOnline = false; //[未升级] 数据库处理 for (int i = 0; i < arrOnlineUsers.Count; i++) { Data.OnlineUserProperties user = (Data.OnlineUserProperties)arrOnlineUsers[i]; if (msgData.Receiver_id == user.User_id) { isFoundOnline = true; DataPackage dataPackage = new DataPackage(); dataPackage.Client = user.Client; dataPackage.Data = bData; Sender sender = new Sender(dataPackage.Client); if (sender.SendMessage(dataPackage)) return; else { //lock (Data.Data.ArrSendingMessages) //{ // Data.Data.ArrSendingMessages.Add(msgData); //} SQLService sql = new SQLService(); sql.InsertIntoOverMessages(msgData); } break; } } if (!isFoundOnline) { SQLService sql = new SQLService(); sql.InsertIntoOverMessages(msgData); } //lock (Data.Data.ArrSendingMessages) //{ // Data.Data.ArrSendingMessages.Add(msgData); //} }
public bool Send() { try { byte[] data = new byte[BufferSize - 4]; Sender sender = new Sender(tcpTarget); int op = 0; while (fsSend.Read(data, op, BufferSize - 4) != 0) { byte[] bResult = new byte[BufferSize]; bPackSendBegin.CopyTo(bResult, 0); data.CopyTo(bResult, 4); DataPackage dpk = new DataPackage(); dpk.Data = data; sender.SendMessage(dpk); } fsSend.Close(); return true; } catch { return false; } }
public bool Response() { try { SQLService sql = new SQLService(); System.Collections.ArrayList arr = sql.SearchAccount(selAcc); foreach (object obj in arr) { Sender sender = new Sender(client); DataPackage dpk = new DataPackage(); AccountInfoConvet converter = new AccountInfoConvet(); dpk.Data = converter.ConvertToBytes((AccountInfo)obj); dpk.Client = client; sender.SendMessage(dpk); } return true; } catch { return false; } }
public void Respect() { Sender sender = new Sender(dataRespect); sender.SendMessage(dataRespect); }
public AccountInfo Response() { Sender sender = new Sender(dataSend.Client); sender.SendMessage(dataSend); return accountInfo; }
public void Response() { Sender sender = new Sender(dataResponse.Client); sender.SendMessage(dataResponse); }