Beispiel #1
0
        /// <summary>
        /// Send button CallBack
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void send_Click(object sender, RoutedEventArgs e)
        {
            var messageToSend = (TextBox)this.FindName("message");

            if (loggedIn)
            {
                remoteObject.SetMessage(String.Concat(pseudo, " : ", messageToSend.Text));
                messageToSend.Text = "";
            }
            else
            {
                messageToSend.Text = "CLIENT NOT CONNECTED";
            }
        }
Beispiel #2
0
        /// <summary>
        /// Remote调用
        /// </summary>
        /// <param name="Cmd"></param>
        /// <param name="timeout"></param>
        /// <param name="dtStr"></param>
        /// <returns></returns>
        public static string RemoteCmd(string url, string Cmd, int timeout, string dtStr)
        {
            string innerErrorMessage = string.Empty;

            string s = null;

            try
            {
                string            httpChannelName = "remoting";
                HttpClientChannel chan            = (HttpClientChannel)ChannelServices.GetChannel(httpChannelName);
                if (chan == null)
                {
                    chan = new HttpClientChannel(httpChannelName, null);

                    IDictionary properties = new Hashtable();
                    properties["name"]    = httpChannelName;
                    properties["timeout"] = timeout;

                    chan = new HttpClientChannel(properties, null);
                    ChannelServices.RegisterChannel(chan, false);
                }

                // Create an instance of the remote object
                MyRemotableObject remoteObject = (MyRemotableObject)Activator.GetObject(typeof(MyRemotableObject), url);
                s = remoteObject.SetMessage(Cmd);
            }
            catch (Exception ex)
            {
                innerErrorMessage = string.Format("JetermClient.Common的RemoteCmd请求抛异常:{0}请求时间:{1}{0}请求url:{0}{2}{0}请求数据:{0}{3}{0}返回:{0}{4}{0}异常信息为:{0}{5}", Environment.NewLine, dtStr, url, Cmd, (string.IsNullOrWhiteSpace(s) ? "返回为空" : s), ex.ToString());
                log.Error(innerErrorMessage);
            }

            if (!string.IsNullOrWhiteSpace(innerErrorMessage))
            {
                throw new Exception(innerErrorMessage);
            }
            return(s);
        }
Beispiel #3
0
 /// <summary>
 /// Logs in a new member
 /// </summary>
 /// <param name="username"></param>
 public void Login(string username)
 {
     usernames.Add(username);
     Console.WriteLine(String.Concat("Received Login from : ", username));
     remotableObject.SetMessage(String.Concat(username, " has joined the conversation"));
 }