Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();
            var callback = new ClientCallback();

            service = new ServiceClient();
            service.Open();

            this.Closed += (e, s) =>
            {
                if (User.Instance.Account != null)
                {
                    service.LogOut(User.Instance.Account.Id);
                }
                service.Close();
            };

            this.Loaded += (e, s) =>
            {
                if (ShowAuthorizationWindow())
                {
                    if (User.Instance.Account != null)
                    {
                        lblInfoFullname.Content = User.Instance.Account.FullName;
                    }
                    RefreshPrj();
                    RefreshTs();
                    RefreshHist();
                }
            };
        }
Exemplo n.º 2
0
        public ClientCallback GetCallbackChannelByID(ObjectId id)
        {
            ClientCallback callbackChannel = null;

            subscribers.TryGetValue(id, out callbackChannel);
            return(callbackChannel);
        }
        public void CallbackExample1()
        {
            //Start service and use net.tcp binding
            ServiceHost   eventServiceHost  = new ServiceHost(typeof(GreetingsService));
            NetTcpBinding tcpBindingpublish = new NetTcpBinding();

            tcpBindingpublish.Security.Mode = SecurityMode.None;
            eventServiceHost.AddServiceEndpoint(typeof(IGreetings), tcpBindingpublish, "net.tcp://localhost:8000/GreetingsService");
            eventServiceHost.Open();

            //Create client proxy
            NetTcpBinding clientBinding = new NetTcpBinding();

            clientBinding.Security.Mode = SecurityMode.None;
            EndpointAddress ep    = new EndpointAddress("net.tcp://localhost:8000/GreetingsService");
            ClientCallback  cb    = new ClientCallback();
            IGreetings      proxy = DuplexChannelFactory <IGreetings> .CreateChannel(new InstanceContext (cb), clientBinding, ep);

            //Call service
            proxy.SendMessage();

            //Wait for callback - sort of hack, but better than using wait handle to possibly block tests.
            Thread.Sleep(1000);

            //Cleanup
            eventServiceHost.Close();

            Assert.IsTrue(CallbackSent, "#1");
            Assert.IsTrue(CallbackReceived, "#1");
        }
Exemplo n.º 4
0
 public void DisconnectClientFromGameManager(ClientCallback callback)
 {
     if (Clients.Contains(callback))
     {
         Clients.Remove(callback);
     }
 }
Exemplo n.º 5
0
 public void DisconnectClientFromGame(string id, ClientCallback callback)
 {
     if (Games[id].Clients.Contains(callback))
     {
         Games[id].Clients.Remove(callback);
     }
 }
Exemplo n.º 6
0
 public void ConnectClientToGameManager(ClientCallback callback)
 {
     if (!Clients.Contains(callback))
     {
         Clients.Add(callback);
     }
 }
Exemplo n.º 7
0
 public void ConnectClientToGame(string id, ClientCallback callback)
 {
     if (!Games[id].Clients.Contains(callback))
     {
         Games[id].Clients.Add(callback);
     }
 }
Exemplo n.º 8
0
        //Constractor
        public BaseWindow(int width, int height)
        {
            var callback = new ClientCallback();

            Host    = new ChatServiceClient(new System.ServiceModel.InstanceContext(callback));
            _window = new Window
            {
                Width  = width,
                Height = height,
                WindowStartupLocation = WindowStartupLocation.CenterScreen,
                ResizeMode            = ResizeMode.NoResize,
                WindowStyle           = WindowStyle.None
            };
            _window.MouseLeftButtonDown += _window_MouseLeftButtonDown;
            //Grid
            _myGrid            = new Grid();
            _window.Content    = _myGrid;
            _myGrid.Background = new SolidColorBrush(Colors.BlueViolet);
            //_myGrid.ShowGridLines = true;

            RowDefinition rowDef = new RowDefinition();

            _myGrid.RowDefinitions.Add(rowDef);
            _myGrid.RowDefinitions[0].Height = new GridLength(30);

            Timer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(15)
            };
            Timer.Tick += Timer_Tick;
        }
Exemplo n.º 9
0
 public void Call(ObjectId receiver)
 {
     if (loginService.LoggedIn)
     {
         ClientCallback receiverCallback = loginService.GetCallbackChannelByID(receiver);
         if (receiver != null)
         {
             receiverCallback.OnCall(loginService.UserId);
         }
     }
 }
Exemplo n.º 10
0
 public void AcceptCall(ObjectId friendId)
 {
     if (loginService.LoggedIn)
     {
         ClientCallback friendCallback = loginService.GetCallbackChannelByID(friendId);
         if (friendCallback != null)
         {
             friendCallback.OnCallAccepted(loginService.UserId);
         }
     }
 }
Exemplo n.º 11
0
        private async Task SendRequest(ObjectId friendId, Friendship friendship)
        {
            await dataBaseService.FriendshipCollection.InsertOneAsync(friendship);

            ClientCallback friendCallback = loginService.GetCallbackChannelByID(friendId);

            if (friendCallback != null)
            {
                friendCallback.OnFriendshipRequested(loginService.UserId);
            }
        }
Exemplo n.º 12
0
        public WcfScServiceClient(string baseAddress, NetTcpBinding binding)
        {
            EndpointAddress serviceAddress = new EndpointAddress(baseAddress);

            IHostingClientServiceCallback evnt = new ClientCallback(this);
            InstanceContext evntCntx           = new InstanceContext(evnt);

            proxy = new EventServiceHostingClient(evntCntx, binding, serviceAddress);

            proxy.ChannelFactory.Faulted += new EventHandler(ChannelFactory_Faulted);
            temp = proxy.Connect();
        }
Exemplo n.º 13
0
 public HandshakeServer(int _port, int _publisherPort, ClientCallback _cb)
 {
     port = _port;
     publisherPort = _publisherPort;
     cb = _cb;
     buf = new byte[1024];
     connectedClients = new List<Socket>();
     server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     var ep = new IPEndPoint(IPAddress.Any, port);
     server.Bind(ep);
     log.InfoFormat("HanshakeServer succesfully binded on port {0}", port);
     server.Listen(10);
 }
Exemplo n.º 14
0
        public HandshakeServer(int _port, int _publisherPort, ClientCallback _cb)
        {
            port             = _port;
            publisherPort    = _publisherPort;
            cb               = _cb;
            buf              = new byte[1024];
            connectedClients = new List <Socket>();
            server           = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            var ep = new IPEndPoint(IPAddress.Any, port);

            server.Bind(ep);
            log.InfoFormat("HanshakeServer succesfully binded on port {0}", port);
            server.Listen(10);
        }
Exemplo n.º 15
0
        public async Task SendMessage(Message msg)
        {
            if (loginService.LoggedIn)
            {
                msg.Read = false;
                await dataBaseService.MessageCollection.InsertOneAsync(msg);

                ClientCallback receiverCallback = loginService.GetCallbackChannelByID(msg.Receiver);
                if (receiverCallback != null)
                {
                    receiverCallback.OnMessageReceived(msg);
                }
            }
        }
Exemplo n.º 16
0
        public async Task Subscribe(JToken data, IWebsocketCallback webcallback)
        {
            userId = ObjectId.Parse(data["id"].ToString());
            ClientCallback callback = new ClientCallback(webcallback);

            subscribers.TryAdd(userId, callback);
            await ChangeStatus(Status.Web);

            ICommunicationObject obj = (ICommunicationObject)webcallback;

            obj.Closed += async(s, e) =>
            {
                await Unsubscribe();
            };
        }
Exemplo n.º 17
0
        public async Task SendMessage(JToken data)
        {
            ObjectId receiver = ObjectId.Parse(data["to"].ToString());
            string   message  = data["message"].ToString();

            Message msg = new Message {
                Sender = loginService.UserId, Receiver = receiver, Hour = String.Format("{0:00}", DateTime.Now.Hour), Minute = String.Format("{0:00}", DateTime.Now.Minute), Read = false, Text = message
            };
            await dataBaseService.MessageCollection.InsertOneAsync(msg);

            ClientCallback receiverCallback = loginService.GetCallbackChannelByID(msg.Receiver);

            if (receiverCallback != null)
            {
                receiverCallback.OnMessageReceived(msg);
            }
        }
Exemplo n.º 18
0
        public async Task ChangeUsername(string username)
        {
            List <ObjectId> friends = await databaseService.GetFriendIdList(loginService.UserId);

            friends.ForEach(friendId =>
            {
                ClientCallback clientCallback = loginService.GetCallbackChannelByID(friendId);
                if (clientCallback != null)
                {
                    clientCallback.OnFriendsUsernameChanged(loginService.UserId, username);
                }
            });

            FilterDefinition <User> filter = Builders <User> .Filter.Eq("_id", loginService.UserId);

            UpdateDefinition <User> update = Builders <User> .Update.Set("username", username);

            await databaseService.UserCollection.UpdateOneAsync(filter, update);
        }
Exemplo n.º 19
0
        public async Task ChangeStatus(Status status)
        {
            List <ObjectId> friendIds = await dataBaseService.GetFriendIdList(userId);

            foreach (ObjectId friendId in friendIds)
            {
                ClientCallback callback = GetCallbackChannelByID(friendId);
                if (callback != null)
                {
                    callback.OnFriendStatusChanged(userId, status);
                }
            }

            FilterDefinition <User> filter = Builders <User> .Filter.Eq("_id", userId);

            UpdateDefinition <User> update = Builders <User> .Update.Set("status", status.ToString());

            await dataBaseService.UserCollection.UpdateOneAsync(filter, update);
        }
Exemplo n.º 20
0
        protected override void CreateChildControls()
        {
            // Create buttons
            button1 = new Button
            {
                ID            = "Button1",
                Text          = "Button 1",
                Visible       = false,
                OnClientClick = "button1Clicked(ID_RECORD, '', callbackComplete);return false;"
            };
            Controls.Add(button1);


            // Create callback controls
            delRECORD = new ClientCallback {
                ID = "delRECORD"
            };
            delRECORD.Raise += delRECORD_Raise;
            Controls.Add(delRECORD);
        }
Exemplo n.º 21
0
        public async Task <Tuple <ObjectId, string> > Subscribe(string userName, string password, string ip, IServerCallback desktopCallback)
        {
            userId = await GetUserId(userName, password);

            if (!userId.Equals(ObjectId.Empty))
            {
                if (subscribers.ContainsKey(userId))
                {
                    Console.WriteLine(userName + " is already connected");
                    return(new Tuple <ObjectId, string>(ObjectId.Empty, "Sie sind schon angemeldet"));
                }
                else
                {
                    FilterDefinition <BsonDocument> filter = Builders <BsonDocument> .Filter.Eq("_id", userId);

                    UpdateDefinition <BsonDocument> update = Builders <BsonDocument> .Update.Set("ip", ip);

                    await dataBaseService.UserBsonCollection.UpdateOneAsync(filter, update);

                    ClientCallback callback = new ClientCallback(desktopCallback);

                    ICommunicationObject obj = (ICommunicationObject)desktopCallback;
                    obj.Closed += async(s, e) =>
                    {
                        await Unsubscribe();
                    };

                    subscribers.TryAdd(userId, callback);

                    await ChangeStatus(Status.Online);

                    Console.WriteLine(userName + " successfully connected with id: " + userId.ToString());

                    return(new Tuple <ObjectId, string>(userId, string.Empty));
                }
            }
            else
            {
                return(new Tuple <ObjectId, string>(ObjectId.Empty, "Passwort oder Benutzername falsch"));
            }
        }
Exemplo n.º 22
0
        public Client(ClientFlags flags)
        {
            spoll = avahi_simple_poll_new();

            pollcb = OnPollCallback;
            avahi_simple_poll_set_func(spoll, pollcb);
            IntPtr poll = avahi_simple_poll_get(spoll);

            cb = OnClientCallback;

            int error;

            handle = avahi_client_new(poll, flags, cb, IntPtr.Zero, out error);
            if (error != 0)
            {
                throw new ClientException(error);
            }

            thread = new Thread(PollLoop);
            thread.IsBackground = true;
            thread.Start();
        }
Exemplo n.º 23
0
        public Server(EndPoint endPoint, ServerType serverType, ClientCallback callback)
        {
            ep   = endPoint;
            type = serverType;
            cb   = callback;
            switch (type)
            {
            case ServerType.Custom:
                TcpListener listenerCustom = new TcpListener((IPEndPoint)ep);
                listenerCustom.Start();
                listenerCustom.BeginAcceptTcpClient(callbackCustom, listenerCustom);
                listener = listenerCustom;
                break;

            case ServerType.File:
                TcpListener listenerFile = new TcpListener((IPEndPoint)ep);
                listenerFile.Start();
                listenerFile.BeginAcceptTcpClient(callbackFile, listenerFile);
                listener = listenerFile;
                break;

            case ServerType.HTTP:
                HttpListener listenerHttp = new HttpListener();
                listenerHttp.Prefixes.Add("http://" + ep.ToString() + "/");
                listenerHttp.Start();
                listenerHttp.BeginGetContext(callBackHTTP, listenerHttp);
                listener = listenerHttp;
                break;

            case ServerType.HTTPS:
                HttpListener listenerHttps = new HttpListener();
                listenerHttps.Prefixes.Add("https://" + ep.ToString() + "/");
                listenerHttps.Start();
                listenerHttps.BeginGetContext(callBackHTTP, listenerHttps);
                listener = listenerHttps;
                break;
            }
        }
Exemplo n.º 24
0
        public async Task ReplyToFriendRequest(ObjectId friendId, bool accept)
        {
            FilterDefinitionBuilder <Friendship> builder = Builders <Friendship> .Filter;
            FilterDefinition <Friendship>        filter  = builder.Eq(f => f.Receiver, loginService.UserId) & builder.Eq(f => f.Requester, friendId);

            if (accept)
            {
                UpdateDefinition <Friendship> update = Builders <Friendship> .Update.Set(f => f.Accepted, accept);

                await dataBaseService.FriendshipCollection.UpdateOneAsync(filter, update);
            }
            else
            {
                await dataBaseService.FriendshipCollection.DeleteOneAsync(filter);
            }

            ClientCallback friendCallback = loginService.GetCallbackChannelByID(friendId);

            if (friendCallback != null)
            {
                friendCallback.OnFriendshipRequestAnswered(loginService.UserId, accept);
            }
        }
Exemplo n.º 25
0
        public MainForm()
        {
            InitializeComponent();

            _browserWrapper = new WebBrowserWrapper(webBrowser);

            var clientCallback = new ClientCallback();

            clientCallback.OnLogoutCommand += (sender, args) =>
            {
                ResetForm();
                ShowMessageBox(args.Message, MessageBoxIcon.Warning);
            };
            clientCallback.OnMessage           += (sender, args) => { ShowMessage(args.Message); };
            clientCallback.OnUserStatusChanged += (sender, args) =>
            {
                var message = new ChatMessage
                {
                    Message = args.IsOnline
                        ? $"Пользователь {args.User.Name} присоеденился к чату."
                        : $"Пользователь {args.User.Name} покинул чат."
                };
                ShowMessage(message);

                UpdateUsersList(args.User, args.IsOnline);
            };
            clientCallback.OnServerStopped += (sender, args) =>
            {
                _doLogoutOnClose = false;
                ShowMessageBox("Получена комманда остановки сервера.");
                Close();
            };

            var channelFactory = new DuplexChannelFactory <IServerService>(clientCallback, "SimpleChatServerEndPoint");

            _server = channelFactory.CreateChannel();
        }
Exemplo n.º 26
0
 private static extern IntPtr avahi_client_new(IntPtr poll, ClientFlags flags, ClientCallback handler,
                                               IntPtr userData, out int error);
Exemplo n.º 27
0
        public void CallbackExample1()
        {
            //Start service and use net.tcp binding
            ServiceHost   eventServiceHost  = new ServiceHost(typeof(GreetingsService));
            NetTcpBinding tcpBindingpublish = new NetTcpBinding();

            tcpBindingpublish.Security.Mode = SecurityMode.None;
            eventServiceHost.AddServiceEndpoint(typeof(IGreetings), tcpBindingpublish, "net.tcp://localhost:8000/GreetingsService");
            var cd = eventServiceHost.Description.Endpoints [0].Contract;

            Assert.AreEqual(2, cd.Operations.Count, "Operations.Count");
            var send = cd.Operations.FirstOrDefault(od => od.Name == "SendMessage");
            var show = cd.Operations.FirstOrDefault(od => od.Name == "ShowMessage");

            Assert.IsNotNull(send, "OD:SendMessage");
            Assert.IsNotNull(show, "OD:ShowMessage");
            foreach (var md in send.Messages)
            {
                if (md.Direction == MessageDirection.Input)
                {
                    Assert.AreEqual("http://tempuri.org/IGreetings/SendMessage", md.Action, "MD:SendMessage");
                }
                else
                {
                    Assert.AreEqual("http://tempuri.org/IGreetings/SendMessageResponse", md.Action, "MD:SendMessage");
                }
            }
            foreach (var md in show.Messages)
            {
                if (md.Direction == MessageDirection.Output)
                {
                    Assert.AreEqual("http://tempuri.org/IGreetings/ShowMessage", md.Action, "MD:ShowMessage");
                }
                else
                {
                    Assert.AreEqual("http://tempuri.org/IGreetings/ShowMessageResponse", md.Action, "MD:ShowMessage");
                }
            }
            eventServiceHost.Open();

            var chd = (ChannelDispatcher)eventServiceHost.ChannelDispatchers [0];

            Assert.IsNotNull(chd, "ChannelDispatcher");
            Assert.AreEqual(1, chd.Endpoints.Count, "ChannelDispatcher.Endpoints.Count");
            var ed = chd.Endpoints [0];
            var cr = ed.DispatchRuntime.CallbackClientRuntime;

            Assert.IsNotNull(cr, "CR");
            Assert.AreEqual(1, cr.Operations.Count, "CR.Operations.Count");
            Assert.AreEqual("http://tempuri.org/IGreetings/ShowMessage", cr.Operations [0].Action, "ClientOperation.Action");

            //Create client proxy
            NetTcpBinding clientBinding = new NetTcpBinding();

            clientBinding.Security.Mode = SecurityMode.None;
            EndpointAddress ep    = new EndpointAddress("net.tcp://localhost:8000/GreetingsService");
            ClientCallback  cb    = new ClientCallback();
            IGreetings      proxy = DuplexChannelFactory <IGreetings> .CreateChannel(new InstanceContext (cb), clientBinding, ep);

            //Call service
            proxy.SendMessage();

            //Wait for callback - sort of hack, but better than using wait handle to possibly block tests.
            Thread.Sleep(2000);

            //Cleanup
            eventServiceHost.Close();

            Assert.IsTrue(CallbackSent, "#1");
            Assert.IsTrue(CallbackReceived, "#2");
        }
Exemplo n.º 28
0
 public BUCDriver(ClientCallback delegetedCallback)
 {
     resultHandler = delegetedCallback;
     Initialize();
 }
Exemplo n.º 29
0
 private void FormClient_Load(object sender, EventArgs e)
 {
     ClientCallback callback = new ClientCallback();
     callback.addMessageToTextbox += new ClientCallback.UpdateTextBoxDelegate(
         AddNewMessage);
     callback.updateUsersList += new ClientCallback.UpdateListDelegate(
         UpdateUsersListbox);
     client = new ChatServiceClient(new InstanceContext(callback));
 }
Exemplo n.º 30
0
        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            string keyFormat = "{0}.{1}.{2}.{3}"; // {ClientHostName}.{ClientName}.{ClientCallback}.{TransactionId}

            return(string.Format(CultureInfo.InvariantCulture, keyFormat, ClientHostName, ClientName, ClientCallback.GetType().FullName, TransactionId));
        }
Exemplo n.º 31
0
        public Client (ClientFlags flags)
        {
            spoll = avahi_simple_poll_new ();

            pollcb = OnPollCallback;
            avahi_simple_poll_set_func (spoll, pollcb);
            IntPtr poll = avahi_simple_poll_get (spoll);
            cb = OnClientCallback;

            int error;
            handle = avahi_client_new (poll, flags, cb, IntPtr.Zero, out error);
            if (error != 0)
                throw new ClientException (error);

            thread = new Thread (PollLoop);
            thread.IsBackground = true;
            thread.Start ();
        }
		public void CallbackExample1 ()
		{
			//Start service and use net.tcp binding
			ServiceHost eventServiceHost = new ServiceHost (typeof (GreetingsService));
			NetTcpBinding tcpBindingpublish = new NetTcpBinding ();
			tcpBindingpublish.Security.Mode = SecurityMode.None;
			eventServiceHost.AddServiceEndpoint (typeof (IGreetings), tcpBindingpublish, "net.tcp://localhost:8000/GreetingsService");
			var cd = eventServiceHost.Description.Endpoints [0].Contract;
			Assert.AreEqual (2, cd.Operations.Count, "Operations.Count");
			var send = cd.Operations.FirstOrDefault (od => od.Name == "SendMessage");
			var show = cd.Operations.FirstOrDefault (od => od.Name == "ShowMessage");
			Assert.IsNotNull (send, "OD:SendMessage");
			Assert.IsNotNull (show, "OD:ShowMessage");
			foreach (var md in send.Messages) {
				if (md.Direction == MessageDirection.Input)
					Assert.AreEqual ("http://tempuri.org/IGreetings/SendMessage", md.Action, "MD:SendMessage");
				else
					Assert.AreEqual ("http://tempuri.org/IGreetings/SendMessageResponse", md.Action, "MD:SendMessage");
			}
			foreach (var md in show.Messages) {
				if (md.Direction == MessageDirection.Output)
					Assert.AreEqual ("http://tempuri.org/IGreetings/ShowMessage", md.Action, "MD:ShowMessage");
				else
					Assert.AreEqual ("http://tempuri.org/IGreetings/ShowMessageResponse", md.Action, "MD:ShowMessage");
			}
			eventServiceHost.Open ();

			var chd = (ChannelDispatcher) eventServiceHost.ChannelDispatchers [0];
			Assert.IsNotNull (chd, "ChannelDispatcher");
			Assert.AreEqual (1, chd.Endpoints.Count, "ChannelDispatcher.Endpoints.Count");
			var ed = chd.Endpoints [0];
			var cr = ed.DispatchRuntime.CallbackClientRuntime;
			Assert.IsNotNull (cr, "CR");
			Assert.AreEqual (1, cr.Operations.Count, "CR.Operations.Count");
			Assert.AreEqual ("http://tempuri.org/IGreetings/ShowMessage", cr.Operations [0].Action, "ClientOperation.Action");

			//Create client proxy
			NetTcpBinding clientBinding = new NetTcpBinding ();
			clientBinding.Security.Mode = SecurityMode.None;
			EndpointAddress ep = new EndpointAddress ("net.tcp://localhost:8000/GreetingsService");
			ClientCallback cb = new ClientCallback ();
			IGreetings proxy = DuplexChannelFactory<IGreetings>.CreateChannel (new InstanceContext (cb), clientBinding, ep);

			//Call service
			proxy.SendMessage ();

			//Wait for callback - sort of hack, but better than using wait handle to possibly block tests.
			Thread.Sleep (2000);

			//Cleanup
			eventServiceHost.Close ();

			Assert.IsTrue (CallbackSent, "#1");
			Assert.IsTrue (CallbackReceived, "#2");
		}
Exemplo n.º 33
0
 private static extern IntPtr avahi_client_new (IntPtr poll, ClientFlags flags, ClientCallback handler,
                                                IntPtr userData, out int error);
Exemplo n.º 34
0
        static void Main(string[] args)
        {
            IClient client  = new ClientCallback();
            string  ses_key = "pape-3pa8-sqoy19";

            HttpListener listener = null;

            try
            {
                listener = new HttpListener();
                listener.Prefixes.Add("http://localhost:1300/simplekerberos/");
                listener.Start();


                while (true)
                {
                    Console.WriteLine("waiting..");
                    HttpListenerContext context = listener.GetContext();
                    string         session      = client.requestForSPN();
                    ResourceServer rs           = new ResourceServer();

                    //string session = "";
                    string user = "";
                    if (session != "")
                    {
                        try
                        {
                            rs.Decrypt(session, ses_key);
                            user = "******";
                        }
                        catch (Exception e)
                        {
                        }
                    }
                    string msg = "";
                    //client.requestForSPN();
                    if (user == "verified")
                    {
                        msg = "<center><b>" + "user is verified with Kerberos" + "<//b></center>" + "<br>";
                    }
                    else
                    {
                        msg = "<center><b>" + "user is not verified with Kerberos please go to login page" + "<//b></center>" + "<br>";
                    }
                    context.Response.ContentLength64 = Encoding.UTF8.GetByteCount(msg);
                    context.Response.StatusCode      = (int)HttpStatusCode.OK;
                    using (Stream stream = context.Response.OutputStream)
                    {
                        using (StreamWriter writer = new StreamWriter(stream))
                        {
                            writer.Write(msg);
                        }
                    }
                    string username = "";


                    Console.WriteLine("msg sent...");
                }
            }
            catch (WebException e)
            {
                Console.WriteLine(e.Status);
            }
        }
		public void CallbackExample1 ()
		{
			//Start service and use net.tcp binding
			ServiceHost eventServiceHost = new ServiceHost (typeof (GreetingsService));
			NetTcpBinding tcpBindingpublish = new NetTcpBinding ();
			tcpBindingpublish.Security.Mode = SecurityMode.None;
			eventServiceHost.AddServiceEndpoint (typeof (IGreetings), tcpBindingpublish, "net.tcp://localhost:8000/GreetingsService");
			eventServiceHost.Open ();

			//Create client proxy
			NetTcpBinding clientBinding = new NetTcpBinding ();
			clientBinding.Security.Mode = SecurityMode.None;
			EndpointAddress ep = new EndpointAddress ("net.tcp://localhost:8000/GreetingsService");
			ClientCallback cb = new ClientCallback ();
			IGreetings proxy = DuplexChannelFactory<IGreetings>.CreateChannel (new InstanceContext (cb), clientBinding, ep);

			//Call service
			proxy.SendMessage ();

			//Wait for callback - sort of hack, but better than using wait handle to possibly block tests.
			Thread.Sleep (1000);

			//Cleanup
			eventServiceHost.Close ();

			Assert.IsTrue (CallbackSent, "#1");
			Assert.IsTrue (CallbackReceived, "#1");
		}
Exemplo n.º 36
0
        private static async Task OnPlayerEvent(IPlayer player, string eventName, object[] args)
        {
            await ConsoleManager.OnPlayerEvent(player, eventName, args);

            await ClientCallback.OnPlayerEvent(player, eventName, args);
        }
Exemplo n.º 37
0
 public ClientService(ClientCallback callback)
 {
     this.Callback = callback;
 }