public Session(Connection connection, SessionProtocol protocol, TemplateRegistry inboundRegistry, TemplateRegistry outboundRegistry) { var inContext = new Context(); inContext.TemplateRegistry.RegisterAll(inboundRegistry); var outContext = new Context(); outContext.TemplateRegistry.RegisterAll(outboundRegistry); inContext.ErrorHandler = this; this.connection = connection; this.protocol = protocol; try { in_stream = new MessageInputStream(connection.InputStream.BaseStream, inContext); out_stream = new MessageOutputStream(connection.OutputStream.BaseStream, outContext); } catch (System.IO.IOException e) { errorHandler.Error(null, "Error occurred in connection.", e); throw new IllegalStateException(e); } protocol.ConfigureSession(this); }
public bool StartSession() { var mymod = ResetModeMod.Instance; if (Main.netMode == 1) { throw new Exception("Clients cannot call this."); } //this.IsExiting = false; // Careful! // Already running? if (this.Data.IsRunning) { LogHelpers.Warn("Session already running"); return(false); } if (mymod.Config.DebugModeInfo) { LogHelpers.Alert(); } this.Data.IsRunning = true; this.Save(); if (Main.netMode == 2) { SessionProtocol.SyncToClients(); } return(true); }
public bool EndSession() { var mymod = ResetModeMod.Instance; if (Main.netMode == 1) { throw new Exception("Clients cannot call this."); } // Already ended? if (!this.Data.IsRunning) { LogHelpers.Alert("Already stopped."); return(false); } if (mymod.Config.DebugModeInfo) { string worldId = WorldHelpers.GetUniqueIdForCurrentWorld(true); LogHelpers.Alert("Sets ALL session data to defaults, stops all TimeLimit \"reset\" commands (world id: " + worldId + ")"); } this.IsExiting = false; this.Data.ResetAll(); this.Save(); if (Main.netMode == 2) { SessionProtocol.SyncToClients(); } this.ResetCurrentWorldForSession(); return(true); }
public void ExpireCurrentWorldInSession(ResetModeMod mymod) { if (mymod.Config.DebugModeInfo) { LogHelpers.Alert("Sets AwaitingNextWorld=true, CurrentSessionedWorldId=\"\", PlayersValidated.Clear()"); } this.Data.AwaitingNextWorld = true; this.Data.CurrentSessionedWorldId = ""; this.Data.PlayersValidated.Clear(); if (Main.netMode != 1) { this.Save(); } if (Main.netMode == 2) { SessionProtocol.SyncToClients(); } if (Main.netMode != 1) { this.GoodExit(); } }
public FastServer(string serverName, SessionProtocol sessionProtocol, Endpoint endpoint) { if (endpoint == null || sessionProtocol == null) { throw new System.NullReferenceException(); } this.endpoint = endpoint; this.sessionProtocol = sessionProtocol; this.serverName = serverName; endpoint.ConnectionListener = this; }
//////////////// public void BeginSessionForPlayer(Player player) { var mymod = ResetModeMod.Instance; mymod.Session.AddPlayer(player); if (Main.netMode == 2) { SessionProtocol.SyncToClient(player.whoAmI); } }
static SessionConstants() { SESSION = new ErrorType("Session"); TEMPLATE_NOT_SUPPORTED = new ErrorCode(SESSION, 11, "TNOTSUPP", "Template not supported", FastAlertSeverity.ERROR); TEMPLATE_UNKNOWN = new ErrorCode(SESSION, 12, "TUNKNOWN", "Template unknown", FastAlertSeverity.ERROR); UNAUTHORIZED = new ErrorCode(SESSION, 13, "EAUTH", "Unauthorized", FastAlertSeverity.FATAL); PROTCOL_ERROR = new ErrorCode(SESSION, 14, "EPROTO", "Protocol Error", FastAlertSeverity.ERROR); CLOSE = new ErrorCode(SESSION, 15, "CLOSE", "Session Closed", FastAlertSeverity.INFO); UNDEFINED = new ErrorCode(SESSION, - 1, "UNDEFINED", "Undefined Alert Code", FastAlertSeverity.ERROR); SCP_1_0 = new SessionControlProtocol_1_0(); SCP_1_1 = new SessionControlProtocol_1_1(); }
static SessionConstants() { SESSION = new ErrorType("Session"); TEMPLATE_NOT_SUPPORTED = new ErrorCode(SESSION, 11, "TNOTSUPP", "Template not supported", FastAlertSeverity.ERROR); TEMPLATE_UNKNOWN = new ErrorCode(SESSION, 12, "TUNKNOWN", "Template unknown", FastAlertSeverity.ERROR); UNAUTHORIZED = new ErrorCode(SESSION, 13, "EAUTH", "Unauthorized", FastAlertSeverity.FATAL); PROTCOL_ERROR = new ErrorCode(SESSION, 14, "EPROTO", "Protocol Error", FastAlertSeverity.ERROR); CLOSE = new ErrorCode(SESSION, 15, "CLOSE", "Session Closed", FastAlertSeverity.INFO); UNDEFINED = new ErrorCode(SESSION, -1, "UNDEFINED", "Undefined Alert Code", FastAlertSeverity.ERROR); SCP_1_0 = new SessionControlProtocol_1_0(); SCP_1_1 = new SessionControlProtocol_1_1(); }
private void OnCurrentClientEnterWorld() { SessionProtocol.SyncToMe(); }
public FastClient(string clientName, SessionProtocol sessionProtocol, Endpoint endpoint) { this.clientName = clientName; this.sessionProtocol = sessionProtocol; this.endpoint = endpoint; }