Exemplo n.º 1
0
        public void ReceiveTunnelCreationRequestFromServiceBinding(IServiceBinding sender, string friendlyName, KeyValuePair <string, int> remoteBinding)
        {
            var tunnel = TunnelManager.GetTunnelByRemoteBinding(remoteBinding);

            if (tunnel == null)
            {
                try
                {
                    var t = TunnelManager.CreateTunnel(friendlyName, remoteBinding);
                    sender.TunnelCreationSucceed(t);
                }
                catch (Exception ex)
                {
                    Logger.ErrorFormat("Failed to create tunnel. Error was: {0}", ex.Message);
                    sender.TunnelCreationFail(2, ex.Message);
                }
            }
            else
            {
                var message = string.Format("Tunnel with remote binding {0}:{1} already exists.", remoteBinding.Key, remoteBinding.Value);
                Logger.Error(message);
                sender.TunnelCreationFail(2, message);
            }
        }