public Result Connect(string address, object o, Action <Msg> connected, Action <Msg> disconnected) { var c = new MsgPackProtocol(this); // subscribe : connected, disconnected logger.Debug($"Connecting. Address:{address}"); using (var wlock = new WriteLock(rwLock)) { protocols[c.ProtocolId] = c; } c.Subscribe(this, (uint)MsgInternal.Connected, OnConnected); c.Subscribe(this, (uint)MsgInternal.Disconnected, OnDisconnected); c.Subscribe(o, (uint)MsgInternal.Connected, connected); c.Subscribe(o, (uint)MsgInternal.Disconnected, disconnected); return(c.Connect(address)); }