protected Disconnect ( ConnectionResult reason = ConnectionResult.FailedUnknown, string customReason = null ) : Task | ||
reason | ConnectionResult | |
customReason | string | |
리턴 | Task |
internal void Connect(MockClientConnection connection) { var c = new MockServerConnection(connection); c.ConnectionId = connection.ConnectionId; connection.connection = c; if (connection.protocols != null) { foreach (Protocol ip in connection.protocols) { Protocol lp; if (!this.protocols.TryGetValue(ip.id, out lp) || !lp.CompatibleWith(ip)) { connection.Disconnect(ConnectionResult.IncompatibleVersion); return; } } } var e = new ConnectionMadeEventArgs(c, null); OnConnectionMade(e); if (e.Rejected) { connection.Disconnect(ConnectionResult.ConnectionFailed); c.Disconnect(ConnectionResult.ConnectionFailed); } }
public void DisconnectedFromConnection() { var test = new AsyncTest <ClientDisconnectedEventArgs> (e => { Assert.IsFalse(e.Requested); Assert.AreEqual(ConnectionResult.EncryptionMismatch, e.Reason); }); client.Connected += (s, e) => connection.Disconnect(ConnectionResult.EncryptionMismatch); client.Disconnected += test.PassHandler; client.ConnectAsync(new Target(Target.AnyIP, 0)); test.Assert(1000); }
internal void Connect(MockClientConnection connection) { var c = new MockServerConnection (connection); c.ConnectionId = connection.ConnectionId; connection.connection = c; if (connection.protocols != null) { foreach (Protocol ip in connection.protocols) { Protocol lp; if (!this.protocols.TryGetValue (ip.id, out lp) || !lp.CompatibleWith (ip)) { connection.Disconnect (ConnectionResult.IncompatibleVersion); return; } } } var e = new ConnectionMadeEventArgs (c, null); OnConnectionMade (e); if (e.Rejected) { connection.Disconnect (ConnectionResult.ConnectionFailed); c.Disconnect (ConnectionResult.ConnectionFailed); } }