Upgrade from SuperSocket 1.4

Keywords: SuperSocket 1.5, SuperSocket 1.4, Upgrade, Naming changes, Configuration changes, Bootstrap

Naming changes

  • ICommandInfo => IRequestInfo
  • ICommandInfo.Data => IRequestInfo.Body
  • BinaryCommandInfo => BinaryRequestInfo
  • StringCommandInfo => StringRequestInfo
  • ICustomProtocol => IReceiveFilter
  • AppSession.SendResponse() => AppSession.Send()
  • AppSession.StartSession() => AppSession.OnSessionStarted()
  • AppSession.HandleExceptionalError(Exception e) => AppSession.HandleException(Exception e)
  • AppServer.OnAppSessionClosed(TAppSession session, CloseReason reason) => AppServer.OnSessionClosed(TAppSession session, CloseReason reason)

Configuration changes

  • Section name was changed: "socketServer" => "superSocket"

Configuration of v1.4:

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <configuration>
  3. <configSections>
  4. <section name="socketServer" type="SuperSocket.SocketEngine.Configuration.SocketServiceConfig, SuperSocket.SocketEngine"/>
  5. </configSections>
  6. <appSettings>
  7. <add key="ServiceName" value="GPSSocketServer"/>
  8. </appSettings>
  9. <socketServer>
  10. ....
  11. </socketServer>
  12. <startup>
  13. <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  14. </startup>
  15. </configuration>

New configuration:

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <configuration>
  3. <configSections>
  4. <section name="superSocket" type="SuperSocket.SocketEngine.Configuration.SocketServiceConfig, SuperSocket.SocketEngine"/>
  5. </configSections>
  6. <appSettings>
  7. <add key="ServiceName" value="GPSSocketServer"/>
  8. </appSettings>
  9. <superSocket>
  10. ....
  11. </superSocket>
  12. <startup>
  13. <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  14. </startup>
  15. </configuration>
  • The attribute "mode"'s available values are changed from "Sync/Async/Udp" to "Tcp/Udp":

v1.4:

  1. mode="Async" or mode="Sync" or mode="Udp"

v1.5:

  1. mode="Tcp" or mode="Udp"
  • The node "services" was changed to be "serverTypes":

v1.4:

  1. <socketServer>
  2. ...
  3. <services>
  4. <service name="GPSSocketService"
  5. type="SuperSocket.QuickStart.GPSSocketServer.GPSServer, SuperSocket.QuickStart.GPSSocketServer" />
  6. </services>
  7. </socketServer>

New:

  1. <superSocket>
  2. ...
  3. <serverTypes>
  4. <add name="GPSSocketService"
  5. type="SuperSocket.QuickStart.GPSSocketServer.GPSServer, SuperSocket.QuickStart.GPSSocketServer" />
  6. </serverTypes>
  7. </superSocket>
  • The attribute "serviceName" of server node was changed to be "serverTypeName":

v1.4:

  1. <server name="GPSSocketServer"
  2. serviceName="GPSSocketService"
  3. ip="Any" port="2012">
  4. </server>

New:

  1. <server name="GPSSocketServer"
  2. serverTypeName="GPSSocketService"
  3. ip="Any" port="2012">
  4. </server>

Logging API changes

  • Logger.LogInfo() => Logger.Info();
  • Logger.LogDebug() => Logger.Debug();
  • Logger.LogError() => Logger.Error();

New bootstrap

The SocketServerManager in v1.4:

  1. var serverConfig = ConfigurationManager.GetSection("socketServer") as SocketServiceConfig;
  2. if (!SocketServerManager.Initialize(serverConfig))
  3. {
  4. race.WriteLine("Failed to initialize SuperSocket!", "Error");
  5. return false;
  6. }
  7. if (!SocketServerManager.Start())
  8. {
  9. Trace.WriteLine("Failed to start SuperSocket!", "Error");
  10. return false;
  11. }

The new bootstrap:

  1. var bootstrap = BootstrapFactory.CreateBootstrap();
  2. if (!bootstrap.Initialize())
  3. {
  4. return false;
  5. }
  6. var result = bootstrap.Start();