tcp.OnCreate+= OnTcpCreate;privatevoidOnTcpCreate( bool reconnected){ // A connection is successfully established. Now you may interactive wit the server cluster}
TCP クライアント - OnException
このイベントは、内部で例外が捕捉された場合や、Connectメソッドが失敗した場合に発生します。
tcp.OnException+= OnTcpException;privatevoidOnTcpException( int errorCode,string errorMessage){ // Handle the exception here}
tcp.OnOffline+= OnTcpOffline;tcp.OnDisconnect+= OnTcpDisconnect;privatevoidOnTcpOffline(){ // We set a flag, so we can perform re-connection in OnDisconnect event listener reconnectFlag =true; // This is raise OnDisconnect eventtcp.Disconnect();}// bool reconnecting is set to true when you use tcp.Reconnect()privatevoidOnTcpDisconnect( bool reconnecting){if (reconnectFlag) { // Call the application server to indirectly obtain a new endpoint here // Assuming we have the new endpoint, we proceed with reconnecttcp.SetEncryptionKeys(newSid, newKey, newIv, newMacKey);tcp.Connect(newAddr, newPort); }}
TCP クライアント - OnDisconnect
このイベントは、クライアントがDiarkisサーバクラスターから正常に切断されたときに発生します。
tcp.OnDisconnect+= OnTcpDisconnect;privatevoidOnTcpDisconnect( bool reconnecting){ // bool reconnecting is set to true only when tcp.Reconnect() is used.}