public void Initialize(IWTSVirtualChannelManager pChannelMgr)
 {
     foreach (var registration in Registrations)
     {
         try
         {
             var callback = new WtsListenerCallback(registration.Key, registration.Value);
             // keep a reference out of paranoia
             Callbacks.Add(callback);
             pChannelMgr.CreateListener(callback.ChannelName, 0, callback);
         }
         catch (Exception ex)
         {
             PluginApplication.Log($"Failed to create listener for '{registration.Key}': {ex}");
         }
     }
 }
            // Called from COM
            void IWTSVirtualChannelCallback.OnClose()
            {
                try
                {
                    if (Parent.isDisposed)
                    {
                        return;
                    }
                    Parent.isDisconnected = true;

                    Parent.Dispose();
                    Parent.Disconnected?.Invoke(this, EventArgs.Empty);
                }
                catch (Exception ex)
                {
                    PluginApplication.Log($"Uncaught exception in OnClose: {ex}");
                }
            }
            // Called from COM
            void IWTSVirtualChannelCallback.OnDataReceived(int cbSize, IntPtr pBuffer)
            {
                var data = new byte[cbSize];

                Marshal.Copy(pBuffer, data, 0, cbSize);

                try
                {
                    if (Parent.isDisposed)
                    {
                        return;
                    }

                    Parent.ReadQueue.WriteMessage(data);
                }
                catch (Exception ex)
                {
                    PluginApplication.Log($"Uncaught exception in ReadMessage: {ex}");
                }
            }
예제 #4
0
        // Called from COM
        void IWTSListenerCallback.OnNewChannelConnection(IWTSVirtualChannel pChannel,
                                                         [MarshalAs(UnmanagedType.BStr)] string data,
                                                         [MarshalAs(UnmanagedType.Bool)] out bool pAccept, out IWTSVirtualChannelCallback pCallback)
        {
            try
            {
                var channel = new DvcClientChannel(ChannelName, pChannel);
                AcceptChannel(channel);

                pAccept   = true;
                pCallback = channel.Proxy;
            }
            catch (Exception ex)
            {
                PluginApplication.Log($"Failure while creating client channel for '{ChannelName}': {ex}");

                pAccept   = false;
                pCallback = null;
            }
        }