/// <summary>
 /// Initializes an instance of RemoteHubSwitchDirect.
 /// </summary>
 /// <param name="clientId">Client id of the local RemoteHub.</param>
 /// <param name="onMessageReceivedCallback">The callback to be used for dealing received private message.</param>
 /// <param name="encoding">The encoder for converting between string and byte array. Default value is Encoding.Default. Will be ignored if type is not string.</param>
 public RemoteHubSwitchDirect(Guid clientId, OnMessageReceivedCallback <T> onMessageReceivedCallback, Encoding encoding = null)
 {
     this.clientId = clientId;
     clientTable.AddOrUpdate(clientId);
     clientSidePrivateMessageCallbackHelper  = new PrivateMessageCallbackHelper <T>(onMessageReceivedCallback);
     adapterSidePrivateMessageCallbackHelper = new PrivateMessageCallbackHelper <byte[]>(null);
     valueConverter = ValueConverter <T> .Create(encoding);
 }
Beispiel #2
0
 /// <summary>
 /// Initializes an instance of StreamAdapter.
 /// </summary>
 /// <param name="inputStream">Stream for reading.</param>
 /// <param name="outputStream">Stream for writing.</param>
 /// <param name="onMessageReceivedCallback">The callback to be used for dealing received private message. Default value is null.</param>
 /// <param name="refreshingIntervalInSeconds">The interval in seconds before sending a data package for keeping it alive when streams are idle. Default value is 60 seconds.</param>
 /// <param name="encoding">The encoder for converting between string and byte array. Default value is Encoding.Default. Will be ignored if type is not string.</param>
 public StreamAdapter(Stream inputStream, Stream outputStream, OnMessageReceivedCallback <T> onMessageReceivedCallback = null, int refreshingIntervalInSeconds = 60, Encoding encoding = null)
     : base(inputStream, outputStream, refreshingIntervalInSeconds)
 {
     privateMessageCallbackHelper = new PrivateMessageCallbackHelper <T>(onMessageReceivedCallback);
     valueConverter = ValueConverter <T> .Create(encoding);
 }