private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (mClient != null && !mClientLoggedIn)
     {
         mClient.Disconnect();
     }
 }
Beispiel #2
0
        public void Disconnect()
        {
            if (eventClient.Connected)
            {
                eventClient.SendBye();
                eventClient.Disconnect();
            }

            Connected = false;
        }
Beispiel #3
0
        /// <summary>
        /// Called when a notification is received by GfW.
        /// </summary>
        /// <param name="notification">The notification information</param>
        /// <param name="callbackContext">The callback context.</param>
        /// <param name="requestInfo">The request info.</param>
        /// <param name="isIdle"><c>true</c> if the user is currently idle;<c>false</c> otherwise</param>
        /// <param name="callbackFunction">The function GfW will run if this notification is responded to on the forwarded computer</param>
        /// <remarks>
        /// Unless your forwarder is going to handle socket-style callbacks from the remote computer, you should ignore
        /// the <paramref name="callbackFunction"/> parameter.
        /// </remarks>
        public override void ForwardNotification(Notification notification,
                                                 CallbackContext callbackContext, RequestInfo requestInfo,
                                                 bool isIdle,
                                                 ForwardedNotificationCallbackHandler callbackFunction)
        {
            try
            {
                Image img      = null;
                var   tempFile = "";

                try
                {
                    var iconType = IconType.ICON_NONE;
                    img = GetImage(notification);
                    if (img != null)
                    {
                        tempFile = Path.GetTempFileName();
                        iconType = IconType.ICON_PNG;
                        img.Save(tempFile, ImageFormat.Png);
                    }

                    EventClient eventClient = new EventClient();

                    if (!eventClient.Connect(Server))
                    {
                        Growl.CoreLibrary.DebugInfo.WriteLine("Could not connect to XBMC server at " + Server);
                        return;
                    }

                    if (
                        !eventClient.SendNotification(ToSingleLine(notification.Title),
                                                      ToSingleLine(notification.Text), iconType, tempFile))
                    {
                        Growl.CoreLibrary.DebugInfo.WriteLine("Error sending notification");
                    }

                    eventClient.Disconnect();
                }
                finally
                {
                    if (img != null)
                    {
                        img.Dispose();
                    }

                    Delete(tempFile);
                }
            }
            catch (Exception ex)
            {
                Growl.CoreLibrary.DebugInfo.WriteLine("XBMC forwarding failed: " + ex.Message);
            }
        }
        static void Main(string[] args)
        {
            Debug.MessageWritten += Debug_MessageWritten;

            Console.Write("연결할 서버 IP 입력 : ");
            string input = Console.ReadLine();
            string ip;

            if (input == "h")
            {
                ip = h_IP;
            }
            else if (input == "c")
            {
                ip = c_IP;
            }
            else if (input == "r")
            {
                ip = r_IP;
            }
            else if (input == "l")
            {
                ip = l_IP;
            }
            else
            {
                ip = input;
            }

            TcpClient   lowClient = new TcpClient(ip, 31006);
            EventClient client    = new EventClient(lowClient, false);

            client.ReceivedMessage      += Client_ReceivedMessage;
            client.FileReceivingStarted += Client_FileReceivingStarted;
            client.FileReceivingEnd     += Client_FileReceivingEnd;
            client.ReceivedLoginResult  += Client_ReceivedLoginResult;

            client.SendMessage("Hello, Server!");

            Console.WriteLine("3초 뒤 맥주 배달...");
            Thread.Sleep(3000);
            SendBeer(99, client);
            Console.WriteLine("맥주 배달 완료!");

            /*client.RequestLogin("wrong", "123qweasd");
             * client.RequestLogin("root", "wrong");
             * client.RequestLogin("root", "123qweasd");
             *
             * TcpDataInsert insert = new TcpDataInsert();
             * List<DatabaseValues> values = new List<DatabaseValues>();
             *
             * values.Add(new DatabaseValues("#2000-8-14#", "99".ToSQLString(), "99".ToSQLString(), "99".ToSQLString(), "김정현".ToSQLString(), "1", "1", "1", "1", "1", "1", "1", "1", "1"));
             * values.Add(new DatabaseValues("#2000-8-14#", "99".ToSQLString(), "99".ToSQLString(), "100".ToSQLString(), "김정현".ToSQLString(), "1", "1", "1", "1", "1", "1", "1", "1", "1"));
             * values.Add(new DatabaseValues("#2000-8-14#", "99".ToSQLString(), "99".ToSQLString(), "101".ToSQLString(), "김정현".ToSQLString(), "1", "1", "1", "1", "1", "1", "1", "1", "1"));
             *
             * insert.ColumnsText = "";
             * insert.TableName = "출석부";
             * insert.Values = values;
             *
             * client.InsertData(insert);
             *
             * TcpDataDelete delete = new TcpDataDelete();
             * delete.TableName = "[출석부]";
             * delete.Where = "[일자]=#2000-8-14# AND 학년=\"99\" AND 반=\"99\" AND 번호=\"99\"";
             *
             * client.DeleteData(delete);*/

            Console.WriteLine("아무키나 누르면 클라이언트를 종료합니다...");
            Console.ReadKey(false);
            client.Disconnect();
        }
 private void MainClientForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     locEvClient.Disconnect();
 }