public void closeConnection() { client.Close(); server.Stop(); OnServerStopped.Invoke(this, new ServerEventArgs("Server stopped.")); }
public override void OnStopServer() { OnServerStopped?.Invoke(); RoomPlayers.Clear(); GamePlayers.Clear(); }
//When server/host is stopped //Perhaps when a delete room button is clicked? Which will result in kicking every one out of the room public override void OnStopServer() { OnServerStopped?.Invoke(); RoomPlayers.Clear(); //Clear the list of existing players, ready for a new game GamePlayers.Clear(); }
public override void OnStopServer() { //Serveri sammutetaan Huone tyhjennetään OnServerStopped?.Invoke(); RoomPlayers.Clear(); GamePlayers.Clear(); }
/// <summary>Stops the server</summary> public void Stop() { Clients = new Dictionary <int, Client>(); _tcpListener.Stop(); UdpListener.Close(); IsRunning = false; OnServerStopped?.Invoke(this, new EventArgs()); }
public override void OnStopServer() { OnServerStopped?.Invoke(); RoomPlayers.Clear(); GamePlayers.Clear(); ServerChangeScene(menuScene); }
private void OnWsServerStopped(object sender, ServerStateEventArgs e) { if (OnServerStopped == null) { _logger?.LogDebug("WebSocket session [{id}] has stop!", e.Id); } else { OnServerStopped?.Invoke(sender, e); } }
private void SetIsRunning(bool run = true) { m_isRunning = run; if (run) { OnServerStarted?.Invoke(); } else { OnServerStopped?.Invoke(); } }
void ProcessNetworkEvent(NetworkEvent e) { switch (e.Type) { case NetEventType.ServerInitialized: OnServerStartSuccess?.Invoke(e); break; case NetEventType.ServerInitFailed: OnServerStartFailure?.Invoke(e); break; // Received after network.StopServer case NetEventType.ServerClosed: OnServerStopped?.Invoke(e); break; case NetEventType.NewConnection: OnNewConnection?.Invoke(e); break; case NetEventType.ConnectionFailed: OnConnectionFailed?.Invoke(e); break; case NetEventType.Disconnected: OnDisconnection?.Invoke(e); break; case NetEventType.ReliableMessageReceived: OnMessageReceived?.Invoke(e, true); break; case NetEventType.UnreliableMessageReceived: OnMessageReceived?.Invoke(e, false); break; } }
void OnMessageReceived(NetworkEvent netEvent, bool reliable) { var bytes = netEvent.GetDataAsByteArray(); var packet = Packet.Deserialize(bytes); // If packet is null, it is a "raw" byte array message. // Forward it to everyone if (packet == null) { OnGetBytes.TryInvoke(netEvent.ConnectionId, bytes, reliable); foreach (var r in ConnectionIds) { // Forward to everyone except the original sender and the server if (r == CId || r == netEvent.ConnectionId) { continue; } Send(Packet.From(CId).To(r).With(ReservedTags.PacketForwarding, packet.Serialize()), true); } return; } string reservedTag = packet.Tag.StartsWith("reserved") ? packet.Tag : string.Empty; // If is not a reserved message if (reservedTag == string.Empty) { OnGetPacket.TryInvoke(netEvent.ConnectionId, packet, reliable); if (NodeState != State.Server) { return; } // The server tries to broadcast the packet to everyone else listed as recipients foreach (var r in packet.Recipients) { // Forward to everyone except the original sender and the server if (r == CId.id || r == netEvent.ConnectionId.id) { continue; } Send(Packet.From(CId).To(r).With(ReservedTags.PacketForwarding, packet.Serialize()), true); } return; } // handle reserved messages switch (reservedTag) { case ReservedTags.ServerStopped: OnServerStopped.TryInvoke(); break; case ReservedTags.ClientJoined: ConnectionIds.Add(netEvent.ConnectionId); OnJoin.TryInvoke(netEvent.ConnectionId); break; case ReservedTags.ClientLeft: ConnectionIds.Remove(netEvent.ConnectionId); OnLeave.TryInvoke(netEvent.ConnectionId); break; case ReservedTags.PacketForwarding: OnGetPacket.TryInvoke(netEvent.ConnectionId, packet, reliable); break; } }
/// <summary> /// When server stops completely. /// </summary> /// <param name="server"></param> private void ServerStopped(NetworkServer server) { _isActive = false; OnServerStopped?.Invoke(server); }
//send event upward private void Server_OnServerStopped(object sender, ServerEventArgs e) { OnServerStopped.Invoke(this, new SimulatorEventArgs(e.Message)); }
/// <summary> /// Handle server stopped notification /// </summary> protected virtual void OnStopped() { OnServerStopped?.Invoke(this, new ServerStateEventArgs(Id)); }
private void ServerStop() { OnServerStopped?.Invoke(); }
protected void OnServerStop(NetworkServer server) => OnServerStopped?.Invoke(server);
public void DoServerStopped() { OnServerStopped?.Invoke(this, EventArgs.Empty); }