Skip to content

Commit 33bc624

Browse files
committed
improved the INewSessionHandler and started to use it in the AppServer
1 parent 67f4c61 commit 33bc624

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

SocketBase/AppServerBase.cs

+8-13
Original file line numberDiff line numberDiff line change
@@ -1173,18 +1173,17 @@ public virtual bool Start()
11731173

11741174
try
11751175
{
1176-
//Will be removed in the next version
1177-
#pragma warning disable 0612, 618
1178-
OnStartup();
1179-
#pragma warning restore 0612, 618
1176+
var newSessionHandler = m_NewSessionHandler;
1177+
if (newSessionHandler != null)
1178+
newSessionHandler.Start();
11801179

11811180
OnStarted();
11821181
}
11831182
catch (Exception e)
11841183
{
11851184
if (Logger.IsErrorEnabled)
11861185
{
1187-
Logger.Error("One exception wa thrown in the method 'OnStartup()'.", e);
1186+
Logger.Error("One exception wa thrown in the method 'OnStarted()'.", e);
11881187
}
11891188
}
11901189
finally
@@ -1199,14 +1198,6 @@ public virtual bool Start()
11991198
return true;
12001199
}
12011200

1202-
/// <summary>
1203-
/// Called when [startup].
1204-
/// </summary>
1205-
[Obsolete("Use OnStarted() instead")]
1206-
protected virtual void OnStartup()
1207-
{
1208-
1209-
}
12101201

12111202
/// <summary>
12121203
/// Called when [started].
@@ -1244,6 +1235,10 @@ public virtual void Stop()
12441235
GC.Collect();
12451236
GC.WaitForFullGCComplete();
12461237

1238+
var newSessionHandler = m_NewSessionHandler;
1239+
if (newSessionHandler != null)
1240+
newSessionHandler.Stop();
1241+
12471242
OnStopped();
12481243

12491244
m_ServerStatus[StatusInfoKeys.IsRunning] = false;

SocketBase/INewSessionHandler.cs

+10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ public interface INewSessionHandler
1717
/// <param name="sessionRegister">The session register.</param>
1818
void Initialize(ISessionRegister sessionRegister);
1919

20+
/// <summary>
21+
/// Starts this instance.
22+
/// </summary>
23+
void Start();
24+
25+
/// <summary>
26+
/// Stops this instance.
27+
/// </summary>
28+
void Stop();
29+
2030
/// <summary>
2131
/// Accepts the new session.
2232
/// </summary>

0 commit comments

Comments
 (0)