public NotifyResponse Post(NotifyChannelRequest request) { NotifyResponse res = new NotifyResponse(); try { //var subscriptionInfos = ServerEvents.GetSubscriptionsDetails(request.ToChannel); //if (subscriptionInfos != null) //{ foreach (string channel in request.ToChannel) { ServerEvents.NotifyChannel(channel, request.Selector, request.Msg); } //} // else // { // Console.WriteLine("No one listening in the Channel: " + request.ToChannel.ToJson()); //} } catch (Exception e) { Console.WriteLine(e.ToJson()); res.ResponseStatus.Message = e.Message; } return(res); }
public NotifyResponse Post(NotifyUserAuthIdRequest request) { NotifyResponse res = new NotifyResponse(); try { Console.WriteLine("Reached in NotifyUserAuthIdRequest"); if (!String.IsNullOrEmpty(request.To_UserAuthId)) { if (request.ToChannel == null) { ServerEvents.NotifyUserId(request.To_UserAuthId, request.Selector, request.Msg); } else { foreach (string channel in request.ToChannel) { ServerEvents.NotifyUserId(request.To_UserAuthId, request.Selector, request.Msg); } } } else { Console.WriteLine("UserAuthId doesn't Exist"); res.ResponseStatus.Message = "UserAuthId doesn't Exist"; } } catch (Exception e) { Console.WriteLine(e.Message + e.StackTrace); res.ResponseStatus.Message = e.Message; } return(res); }
public void Any(PostRawToChannel request) { if (!IsAuthenticated && AppSettings.Get("LimitRemoteControlToAuthenticatedUsers", false)) { throw new HttpError(HttpStatusCode.Forbidden, "You must be authenticated to use remote control."); } // Ensure the subscription sending this notification is still active var sub = ServerEvents.GetSubscriptionInfo(request.From); if (sub == null) { throw HttpError.NotFound("Subscription {0} does not exist".Fmt(request.From)); } // Check to see if this is a private message to a specific user if (request.ToUserId != null) { // Only notify that specific user ServerEvents.NotifyUserId(request.ToUserId, request.Selector, request.Message); } else { // Notify everyone in the channel for public messages ServerEvents.NotifyChannel(request.Channel, request.Selector, request.Message); } }
private void ShowSettings() { try { var settingsDialogVm = new SettingsViewModel(_serverName, _port, _networkInterface); var settingsDialog = new ServerSettingsView { DataContext = settingsDialogVm }; settingsDialog.Owner = Application.Current.MainWindow; if (settingsDialog.ShowDialog() == true) { ServerName = settingsDialogVm.Name; _port = settingsDialogVm.Port; _networkInterface = settingsDialogVm.SelectedNetworkInterface; var ipAddress = _networkInterface.GetIPProperties().UnicastAddresses.First(x => x.Address.AddressFamily == AddressFamily.InterNetwork); //получает IPv4 _ipEndPoint = new IPEndPoint(ipAddress.Address, _port); StopServer(); _tcpListener = new TcpListener(_ipEndPoint); // _tcpListener = new TcpListener(_ipAddress, _port); StartServer(); } } catch (Exception e) { ServerEvents.Add(new ServerEvent(ServerEventEnum.Error, DateTime.Now, e.ToString())); } }
[EventMethod] // When client finishes updating assets public void OnAssetReady(AssetsReadyPacket packet) { var player = Server.GetPlayer(packet.UserId); if (player != null) { player.AssetsReady = true; } var client = ServerTcpHandler.GetClient(packet.ClientId); // update chunks for that player ChunkProvider.CheckChunks(player); // make the player itself appear client.Send(new PlayerPacket() { Name = player.Login, SpriteIndex = player.SpriteIndex, UserId = player.UserId, X = player.X, Y = player.Y, Speed = player.speed }); ServerEvents.Call(new PlayerJoinEvent() { Player = player }); }
public void Stop(string reason = "") { Logger.Info("%server_stop"); this.mineNETConfig.Save <MineNETConfig>(); this.serverConfig.Save <ServerConfig>(); Player[] players = this.GetPlayers(); for (int i = 0; i < players.Length; ++i) { if (string.IsNullOrEmpty(reason)) { players[i].Close(this.mineNETConfig.ServerStopText); } else { players[i].Close(reason); } } this.PluginManager.DisablePlugins(); this.UnloadWorld(); this.NetworkManager.Server.UDPClientClose(); ServerEvents.OnServerStop(new ServerStopEventArgs()); this.Kill(); }
public static void Initialize() { if (singleton == null) { singleton = new ServerEvents(); } }
/// <summary> /// Send CRUD notifications for a ActivityLog Entity or Entities /// Note! : /// This Method is a special method used by the service when ServerEvents are being used.(serviceStack). /// If the service does not implement serverEvents this will throw an error. /// This will send a notification to all subscribed clients (including the client the request originated from) where the chanel name is the name of the entity type. /// This will only process SelectorTypes.store and SelectorTypes.delete notifications. /// The notification sent to subscribers will be a ServerEventMessage (serviceStack) where the data(json) is set as ServerEventMessageData (Jars) object. /// </summary> /// <param name="crud">The notification request indicating a store or delete event that will be sent to other subscribers.</param> public virtual void Any(ActivityLogsNotification crud) { ExecuteFaultHandledMethod(() => { SubscriptionInfo subscriber = ServerEvents.GetSubscriptionInfo(crud.FromUserName); if (subscriber == null) { throw HttpError.NotFound($"Subscriber {crud.FromUserName} does not exist."); } //do some job updates here using the info from the the crud //IActivityLogRepository _repository = _DataRepositoryFactory.GetDataRepository<IActivityLogRepository>(); var _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <ActivityLog, IDataContextNhJars> >(); if (crud.Selector == SelectorTypes.store) { crud.Logs = _repository.CreateUpdateList(crud.Logs.ConvertAllTo <ActivityLog>().ToList(), crud.FromUserName).ConvertAllTo <ActivityLogDto>().ToList(); ServerEvents.NotifyChannel(typeof(ActivityLog).Name, crud.Selector, crud.Logs);//.ConvertToJarsSyncStoreEvent()); } if (crud.Selector == SelectorTypes.delete) { _repository.DeleteList(crud.Logs.ConvertAllTo <ActivityLog>().ToList()); ServerEvents.NotifyChannel(typeof(ActivityLog).Name, crud.Selector, crud.Logs.Select(l => l.Id)); } }); }
/// <summary> /// Send CRUD notifications for a StandardAppointmentException Entity or Entities /// Note! : /// This Method is a special method used by the service when ServerEvents are being used.(serviceStack). /// If the service does not implement serverEvents this will throw an error. /// This will send a notification to all subscribed clients (including the client the request originated from) where the chanel name is the name of the entity type. /// This will only process SelectorTypes.store and SelectorTypes.delete notifications. /// The notification sent to subscribers will be a ServerEventMessage (serviceStack) where the data(json) is set as ServerEventMessageData (Jars) object. /// </summary> /// <param name="crud">The notification request indicating a store or delete event that will be sent to other subscribers.</param> public virtual void Any(StandardAppointmentExceptionsCrudNotification crud) { ExecuteFaultHandledMethod(() => { //check that the sender has subscribed to the service //SubscriptionInfo subscriber = ServerEvents.GetSubscriptionInfo(crud.From); List <SubscriptionInfo> subscriber = ServerEvents.GetSubscriptionInfosByUserId(crud.FromUserName); if (subscriber == null) { throw HttpError.NotFound($"Subscriber {crud.FromUserName} does not exist."); } //do some StandardAppointmentException updates here using the info from the the crud //IStandardAppointmentExceptionRepository _repository = _DataRepositoryFactory.GetDataRepository<IStandardAppointmentExceptionRepository>(); var _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <StandardAppointmentException, IDataContextNhJars> >(); if (crud.Selector == SelectorTypes.store) { IList <StandardAppointmentException> exList = crud.AppointmentExceptions.ToList().ConvertAll(x => x.ConvertTo <StandardAppointmentException>()); exList = _repository.CreateUpdateList(exList, crud.FromUserName).ToList(); crud.AppointmentExceptions = exList.ToList().ConvertAll(x => x.ConvertTo <StandardAppointmentExceptionDto>()); ServerEvents.NotifyChannel(typeof(StandardAppointmentException).Name, crud.AppointmentExceptions);//.ConvertToJarsSyncStoreEvent()); } if (crud.Selector == SelectorTypes.delete) { IList <StandardAppointmentException> exList = crud.AppointmentExceptions.ToList().ConvertAll(x => x.ConvertTo <StandardAppointmentException>()); _repository.DeleteList(exList); ServerEvents.NotifyChannel(typeof(StandardAppointmentException).Name, crud.AppointmentExceptions.Select(a => a.Id)); } }); }
public void ErrorStop(Exception e, bool sendExceptionMessage = false) { this.Logger = new Logger(); Logger.Fatal(e.ToString()); Logger.Error("%server_stop_error"); Logger.Info("%server_stop"); this.mineNETConfig?.Save <MineNETConfig>(); this.serverConfig?.Save <ServerConfig>(); Player[] players = this.GetPlayers(); if (players != null) { for (int i = 0; i < players.Length; ++i) { if (sendExceptionMessage) { players[i].Close(e.ToString()); } else { players[i].Close(this.mineNETConfig.ServerStopText); } } } this.UnloadWorld(); this.NetworkManager?.Server?.UDPClientClose(); ServerEvents.OnServerStop(new ServerStopEventArgs()); this.Kill(); }
public void ListenServerEvents() { Task.Run(() => { try { while (true) { ServerEvents.RaiseEvent(ExpectEvent()); } } catch (Exception e) when( e is SerializationException || e is EndOfStreamException || e is ObjectDisposedException || e is IOException) { Utils.MessageBox.ShowException(e); } finally { if (!_isClosing) { MessageBox.Show("Une erreur est survenue : le serveur n'est plus accessible.", "Erreur - Serveur inaccessible", MessageBoxButton.OK, MessageBoxImage.Error); Disconnect(); Application.Current.Dispatcher.Invoke(() => { ((MainWindow)Application.Current.MainWindow).SetView <MainView>(); }); } } }); }
public object Any(EchoRequest request) { ServerEvents.NotifyChannel("default-channel", "cmd.echo", request.ToEcho); return(new EchoResponse { Echoed = request.ToEcho }); }
public override void Initialize(List <string> arguments) { lobbyMode = arguments[0].Equals("new game") ? LobbyMode.NEW_GAME : arguments[0].Equals("load game") ? LobbyMode.LOAD_GAME : LobbyMode.ONLY_SERVER; ServerEvents.Initialize(); ServerEvents.singleton.StartAgrs = arguments; if (lobbyMode == LobbyMode.LOAD_GAME) { allProfiles = new List <List <string> >(); for (int i = 2; i < arguments.Count; i++) { List <string> toAdd = new List <string>(); toAdd.AddRange(arguments[i].Split(new [] { '|' }, StringSplitOptions.RemoveEmptyEntries)); allProfiles.Add(toAdd); } loadedGameName = arguments[1]; } else { profile = new GameProfile().Serialize(); ServerEvents.singleton.NewWorldName = "World " + GameManager.rnd.Next(); ServerEvents.singleton.SeedToGenerate = "5"; ServerEvents.singleton.SeedToSpawn = "4"; profileName = "Player " + GameManager.rnd.Next(); } }
/// <summary> /// Send CRUD notifications for a ApptLabel Entity or Entities /// Note! : /// This Method is a special method used by the service when ServerEvents are being used.(serviceStack). /// If the service does not implement serverEvents this will throw an error. /// This will send a notification to all subscribed clients (including the client the request originated from) where the chanel name is the name of the entity type. /// This will only process SelectorTypes.store and SelectorTypes.delete notifications. /// The notification sent to subscribers will be a ServerEventMessage (serviceStack) where the data(json) is set as ServerEventMessageData (Jars) object. /// </summary> /// <param name="crud">The notification request indicating a store or delete event that will be sent to other subscribers.</param> public virtual void Any(ApptLabelsNotification crud) { //ExecuteFaultHandledMethod(() => //{ //check that the sender has subscribed to the service var subscriber = ServerEvents.GetSubscriptionsDetails(typeof(ApptLabel).Name); if (subscriber == null) { return; } var _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <ApptLabel, IDataContextNhJars> >(); if (crud.Selector == SelectorTypes.store) { List <ApptLabelDto> notifyList = _repository.Where(l => crud.Ids.Contains(l.Id)).ConvertAllTo <ApptLabelDto>().ToList(); TrySendStoreNotificationToChannel(typeof(ApptLabel).Name, notifyList.ToJson()); } if (crud.Selector == SelectorTypes.delete) { TrySendDeleteNotificationToChannel(typeof(ApptLabel).Name, crud.Ids.ConvertTo <List <string> >().ToArray());//, true); } //}); }
public void OnLogin(LoginPacket packet) { var client = ServerTcpHandler.GetClient(packet.ClientId); try { var user = AccountService.Login(packet.Login, packet.Password); Log.Info("Sending Login Response"); client.Send(new LoginResponsePacket() { SessionId = user.SessionId, UserId = user.UserId, xLocation = user.X, yLocation = user.Y }); ServerEvents.Call(new PlayerLoginEvent() { Player = user, Client = client }); } catch (AccountError e) { Log.Info("Sending Login Error"); client.Send(new DialogPacket() { Message = e.ErrorMessage }); } }
/// <summary> /// Process environment commands. /// </summary> /// <param name="request">The request.</param> public void Post(EnvironmentCommand request) { switch (request.Command) { case EnvironmentCommands.Start: GameController.Start(); break; case EnvironmentCommands.Reset: GameController.Reset(); break; } var status = GameController.GetEnvironmentStatus(); switch (status.Item1) { case EnvironmentStatus.Registering: ServerEvents.NotifyAll(new GetReadyMessage { Dragons = status.Item3 }); break; case EnvironmentStatus.Active: ServerEvents.NotifyChannel("player", new EnvironmentStatusMessage { Status = status.Item1, Dragons = status.Item3 }); break; } ServerEvents.NotifyAll(new EnvironmentStatusMessage { Status = status.Item1, Dragons = status.Item3 }); }
private bool ParseServerEventsFromServerEventsDTO(List <ServerEventsDTO> serverEventsDTO, out List <ServerEvents> serverEvents) { serverEvents = new List <ServerEvents>(); int i = 0; while (i < serverEventsDTO.Count) { try { ServerEvents serverEvent = (ServerEvents)serverEventsDTO[i].Id; if (serverEvent.ToString().ToUpper() != serverEventsDTO[i].Name.ToUpper()) { return(false); } serverEvents.Add(serverEvent); } catch (Exception) { return(false); } i++; } return(true); }
public void Any(PostObjectToChannel request) { if (request.ToUserId != null) { if (request.CustomType != null) { ServerEvents.NotifyUserId(request.ToUserId, request.Selector ?? Selector.Id <CustomType>(), request.CustomType); } if (request.SetterType != null) { ServerEvents.NotifyUserId(request.ToUserId, request.Selector ?? Selector.Id <SetterType>(), request.SetterType); } } else { if (request.CustomType != null) { ServerEvents.NotifyChannel(request.Channel, request.Selector ?? Selector.Id <CustomType>(), request.CustomType); } if (request.SetterType != null) { ServerEvents.NotifyChannel(request.Channel, request.Selector ?? Selector.Id <SetterType>(), request.SetterType); } } }
public async Task Any(PostObjectToChannel request) { if (request.ToUserId != null) { if (request.CustomType != null) { await ServerEvents.NotifyUserIdAsync(request.ToUserId, request.Selector ?? Selector.Id <CustomType>(), request.CustomType); } if (request.SetterType != null) { await ServerEvents.NotifyUserIdAsync(request.ToUserId, request.Selector ?? Selector.Id <SetterType>(), request.SetterType); } } else { if (request.CustomType != null) { await ServerEvents.NotifyChannelAsync(request.Channel, request.Selector ?? Selector.Id <CustomType>(), request.CustomType); } if (request.SetterType != null) { await ServerEvents.NotifyChannelAsync(request.Channel, request.Selector ?? Selector.Id <SetterType>(), request.SetterType); } } }
public void HandleConsoleCommand(string msg) { CommandSender sender = new ConsoleSender(); ServerCommandEventArgs serverCommandEvent = new ServerCommandEventArgs(sender, msg); ServerEvents.OnServerCommand(serverCommandEvent); if (serverCommandEvent.IsCancel) { return; } string[] args = serverCommandEvent.Message.Split(' '); string cmd = args[0]; if (args.Length != 1) { List <string> tmp = new List <string>(args); tmp.RemoveAt(0); args = tmp.ToArray(); } else { args = new string[0]; } this.CommandHandler.CommandHandle(sender, cmd, args); }
/// <summary> /// Send CRUD notifications for a JarsJob Entity or Entities /// Note! : /// This Method is a special method used by the service when ServerEvents are being used.(serviceStack). /// If the service does not implement serverEvents this will throw an error. /// This will send a notification to all subscribed clients (including the client the request originated from) where the chanel name is the name of the entity type. /// This will only process SelectorTypes.store and SelectorTypes.delete notifications. /// The notification sent to subscribers will be a ServerEventMessage (serviceStack) where the data(json) is set as ServerEventMessageData (Jars) object. /// </summary> /// <param name="crud">The notification request indicating a store or delete event that will be sent to other subscribers.</param> public virtual void Any(JarsJobsNotification crud) { //ExecuteFaultHandledMethod(() => //{ //check that the sender has subscribed to the service //SubscriptionInfo subscriber = ServerEvents.GetSubscriptionInfo(crud.From); List <SubscriptionInfo> subscriber = ServerEvents.GetSubscriptionInfosByUserId(crud.FromUserName); if (subscriber == null) { throw HttpError.NotFound($"Subscriber {crud.FromUserName} does not exist."); } //do some job updates here using the info from the the crud IJarsJobRepository _repository = _DataRepositoryFactory.GetDataRepository <IJarsJobRepository>(); //first determine if the Dto objects are full or not, if they are then fill the counterpart objects if (crud.Selector == SelectorTypes.store) { crud.Jobs = _repository.CreateUpdateList(crud.Jobs.ConvertAllTo <JarsJob>().ToList(), crud.FromUserName).ConvertAllTo <JarsJobDto>().ToList(); ServerEvents.NotifyChannel(typeof(JarsJob).Name, crud.Selector, crud.Jobs); } if (crud.Selector == SelectorTypes.delete) { _repository.DeleteList(crud.Jobs.ConvertAllTo <JarsJob>().ToList()); ServerEvents.NotifyChannel(typeof(JarsJob).Name, crud.Selector, crud.Jobs.Select(j => j.Id)); } //}); }
private void StopServer() { try { if (_tcpListener != null) { Application.Current.Dispatcher.Invoke(delegate { foreach (var client in ClientsOnServer) { client.TcpClient.PutDataToStream(new NetworkCommand(NetworkCommandTypes.ServerStop)); } _tcpListener.Server.Close(); _tcpListener.Stop(); _isServerRun = false; _thread.Abort(); ServerEvents.Add(new ServerEvent(ServerEventEnum.Stop, DateTime.Now)); }); } } catch (Exception e) { ServerEvents.Add(new ServerEvent(ServerEventEnum.Error, DateTime.Now, e.ToString())); } }
/// <summary> /// Send CRUD notifications for a StandardAppointment Entity or Entities /// Note! : /// This Method is a special method used by the service when ServerEvents are being used.(serviceStack). /// If the service does not implement serverEvents this will throw an error. /// This will send a notification to all subscribed clients (including the client the request originated from) where the chanel name is the name of the entity type. /// This will only process SelectorTypes.store and SelectorTypes.delete notifications. /// The notification sent to subscribers will be a ServerEventMessage (serviceStack) where the data(json) is set as ServerEventMessageData (Jars) object. /// </summary> /// <param name="crud">The notification request indicating a store or delete event that will be sent to other subscribers.</param> public virtual void Any(StandardAppointmentsNotification crud) { ExecuteFaultHandledMethod(() => { //Task.Delay(200).Wait(); //check that the sender has subscribed to the service //SubscriptionInfo subscriber = ServerEvents.GetSubscriptionInfo(crud.From); List <SubscriptionInfo> subscriber = ServerEvents.GetSubscriptionInfosByUserId(crud.FromUserName); if (subscriber == null) { throw HttpError.NotFound($"Subscriber {crud.FromUserName} does not exist."); } //do some StandardAppointment updates here using the info from the the crud //IStandardAppointmentRepository _repository = _DataRepositoryFactory.GetDataRepository<IStandardAppointmentRepository>(); var _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <StandardAppointment, IDataContextNhJars> >(); if (crud.Selector == SelectorTypes.store) { IList <StandardAppointmentDto> storeApptList = _repository.Where(a => crud.Ids.Contains(a.Id), true).ToStandardAppointmentDtoList(); TrySendStoreNotificationToChannel(typeof(StandardAppointment).Name, storeApptList.ToJson());//, true); } if (crud.Selector == SelectorTypes.delete) { TrySendDeleteNotificationToChannel(typeof(StandardAppointment).Name, crud.Ids.ConvertTo <List <string> >().ToArray());//, true); } }); }
public async Task <object> Any(PostChatToChannel request) { // Ensure the subscription sending this notification is still active var sub = ServerEvents.GetSubscriptionInfo(request.From); if (sub == null) { throw HttpError.NotFound("Subscription {0} does not exist".Fmt(request.From)); } var channel = request.Channel; var chatMessage = request.Message.IndexOf("{{", StringComparison.Ordinal) >= 0 ? await HostContext.AppHost.ScriptContext.RenderScriptAsync(request.Message, new Dictionary <string, object> { [nameof(Request)] = Request }) : request.Message; // Create a DTO ChatMessage to hold all required info about this message var msg = new ChatMessage { Id = ChatHistory.GetNextMessageId(channel), Channel = request.Channel, FromUserId = sub.UserId, FromName = sub.DisplayName, Message = chatMessage.HtmlEncode(), }; // Check to see if this is a private message to a specific user if (request.ToUserId != null) { // Mark the message as private so it can be displayed differently in Chat msg.Private = true; // Send the message to the specific user Id await ServerEvents.NotifyUserIdAsync(request.ToUserId, request.Selector, msg); // Also provide UI feedback to the user sending the private message so they // can see what was sent. Relay it to all senders active subscriptions var toSubs = ServerEvents.GetSubscriptionInfosByUserId(request.ToUserId); foreach (var toSub in toSubs) { // Change the message format to contain who the private message was sent to msg.Message = $"@{toSub.DisplayName}: {msg.Message}"; await ServerEvents.NotifySubscriptionAsync(request.From, request.Selector, msg); } } else { // Notify everyone in the channel for public messages await ServerEvents.NotifyChannelAsync(request.Channel, request.Selector, msg); } if (!msg.Private) { ChatHistory.Log(channel, msg); } return(msg); }
void OnDebugStateReceived(string objString) { var obj = _serializer.Deserialize <DebugState>(objString); ServerEvents.Publish(new DebugWriterWriteMessage { DebugState = obj }); }
void OnMemoReceived(string objString) { // DO NOT use publish as memo is of type object // and hence won't find the correct subscriptions var obj = _serializer.Deserialize <DesignValidationMemo>(objString); ServerEvents.PublishObject(obj); }
void OnDebugStateReceived(string objString) { var obj = _serializer.Deserialize <DebugState>(objString); Dev2Logger.Log.Info(string.Format("Debug Item Received ID {0}" + Environment.NewLine + "Parent ID:{1}" + "Name: {2}", obj.EnvironmentID, obj.ParentID, obj.Name)); ServerEvents.Publish(new DebugWriterWriteMessage { DebugState = obj }); }
/// <summary> /// 解散房间 /// </summary> private void Destroy() { brocast(SelectProtocol.DESTORY_BRO, null); if (missionId != -1) { ScheduleUtil.Instance.RemoveMission(missionId); } ServerEvents.destorySelect(GetArea()); }
public void Recieve() { DateTime lastPingCheck = DateTime.MinValue; Log.Debug("Starting Listener for client " + ConnectionId); Listening = true; while (Listening) { try { // Check if needs to ping the client to see if its ok DateTime now = DateTime.Now; if (now > lastPingCheck.AddSeconds(PING_CHECK_SECONDS)) { lastPingCheck = now; CheckPing(); } // Read data from socket var socketData = ReadData(); if (socketData == null) { continue; } var packetRead = PacketSerializer.Deserialize(socketData); if (packetRead != null && packetRead is BasePacket) { var packet = (BasePacket)packetRead; packet.ClientId = ConnectionId; if (typeof(PingPacket) == packet.GetType()) { RecievePing((PingPacket)packet); } else { Log.Debug($"Packet {packet.GetType().Name} recieved"); // Put the packet to be processed by the main thread Server.PacketsToProccess.Enqueue(packet); } } } catch (Exception e) { Listening = false; } } ServerEvents.Call(new PlayerQuitEvent() { Client = this, Player = OnlinePlayer, Reason = QuitReason.DISCONNECTED }); Stop(); }
public CheckSubscriptionId_IsActiveResponse Post(CheckSubscriptionId_IsActiveRequest request) { CheckSubscriptionId_IsActiveResponse res = new CheckSubscriptionId_IsActiveResponse { IsActive = ServerEvents.Pulse(request.ToSubscriptionId) }; return(res); }
/// <summary> /// Cancel a server event /// </summary> /// <param name="e">The event you want to cancel</param> public static void CancelServerEvent(ServerEvents e) { switch (e) { case ServerEvents.ConsoleCommand: Server.cancelcommand = true; break; case ServerEvents.ServerAdminLog: Server.canceladmin = true; break; case ServerEvents.ServerLog: Server.cancellog = true; break; case ServerEvents.ServerOpLog: Server.canceloplog = true; break; } }