private void AddPackage(NetPackage package) { if (package == null) { return; } if (package.RemoteEP.Port != NetService.SocketSendPort) { return; } package.RemoteEP.Port = NetService.SocketReadPort; if (package.CommandID != NetCommandType.RemoveProcessedPackage) { OutgoingPackagePool.AddFirst(NetPackageGenerater.TellReceived(package.ID, package.RemoteEP)); } string key = UserInfo.ToUserToken(package.RemoteEP); Sender sender = null; if (m_senders.ContainsKey(key)) { sender = m_senders[key]; } else { sender = new Sender(package.RemoteEP); m_senders.Add(key, sender); } sender.AddPackage(package); }
private bool thread_outgoing(int ellapse) { s_tempPackages.Clear(); OutgoingPackagePool.GrabProcessPackages(ellapse, s_tempPackages, 5); OutgoingPackagePool.DequeueUnprocess(s_tempPackages); foreach (NetPackage p in s_tempPackages) { if (p.OrderID == 1) { Logger.CounterCommand_Send((NetCommandType)p.CommandID); if (p.CommandID != NetCommandType.RemoveProcessedPackage && p.CommandID != NetCommandType.AddUser) { UserInfo userinfo = UserInfoManager.FindUser(p.RemoteEP); string user = (userinfo == null) ? "no user" : userinfo.Username; Logger.WriteLine(string.Format("--->> Command: {0}. Package ID: {1}. Target User: {2}", p.CommandID, p.ID, user)); } } int length = m_send_socket.SendTo(p.Buffer, p.Buffer.Length, SocketFlags.None, p.RemoteEP); } OutgoingPackagePool.RemoveDeadProcessed(); return(s_tempPackages.Count != 0); }
private void thread_refresh_user_list(int ellapse) { user_refresh_timer += ellapse; if (user_refresh_timer > broadcast_timer_array[broadcast_timer_array_index]) { if (broadcast_timer_array_index + 1 < broadcast_timer_array.Length) { broadcast_timer_array_index++; } user_refresh_timer = 0; OutgoingPackagePool.AddFirst(NetPackageGenerater.BroadcastFindUser()); } }
static OutgoingPackagePool() { s_singleton = new OutgoingPackagePool(); }