SuperSocket 1.5 Documentation译文 21 ----- 升级SuperSocket1.4
SuperSocket1.4升级
命名变化
- 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)
配置变化
-
节点变化: "socketServer" => "superSocket"
Configuration v1.4:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="socketServer" type="SuperSocket.SocketEngine.Configuration.SocketServiceConfig, SuperSocket.SocketEngine"/> </configSections> <appSettings> <add key="ServiceName" value="GPSSocketServer"/> </appSettings> <socketServer> .... </socketServer> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /> </startup> </configuration>
新节点:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="superSocket" type="SuperSocket.SocketEngine.Configuration.SocketServiceConfig, SuperSocket.SocketEngine"/> </configSections> <appSettings> <add key="ServiceName" value="GPSSocketServer"/> </appSettings> <superSocket> .... </superSocket> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /> </startup> </configuration>
-
属性"mode" 的可用值从"Sync/Async/Udp" 变为 "Tcp/Udp":
v1.4:
mode="Async" or mode="Sync" or mode="Udp"
v1.5:
mode="Tcp" or mode="Udp"
-
节点 "services" 变为 "serverTypes":
v1.4:
<socketServer> ... <services> <service name="GPSSocketService" type="SuperSocket.QuickStart.GPSSocketServer.GPSServer, SuperSocket.QuickStart.GPSSocketServer" /> </services> </socketServer>
新增:
<superSocket> ... <serverTypes> <add name="GPSSocketService" type="SuperSocket.QuickStart.GPSSocketServer.GPSServer, SuperSocket.QuickStart.GPSSocketServer" /> </serverTypes> </superSocket>
-
服务节点属性 "serviceName" 变为 "serverTypeName":
v1.4:
<server name="GPSSocketServer" serviceName="GPSSocketService" ip="Any" port="2012"> </server>
新增:
<server name="GPSSocketServer" serverTypeName="GPSSocketService" ip="Any" port="2012"> </server>
日志 API 变化
- Logger.LogInfo() => Logger.Info();
- Logger.LogDebug() => Logger.Debug();
- Logger.LogError() => Logger.Error();
新的引导程序
v1.4版本的SocketServerManager :
var serverConfig = ConfigurationManager.GetSection("socketServer") as SocketServiceConfig; if (!SocketServerManager.Initialize(serverConfig)) { race.WriteLine("Failed to initialize SuperSocket!", "Error"); return false; } if (!SocketServerManager.Start()) { Trace.WriteLine("Failed to start SuperSocket!", "Error"); return false; }
新的引导程序:
var bootstrap = BootstrapFactory.CreateBootstrap(); if (!bootstrap.Initialize()) { return false; } var result = bootstrap.Start();