예제 #1
0
        private void Iph_Connect(object sender, ConnectEventArgs args)
        {
            if (iph.IsConnected)
            {
                label4.Text = "Connected to [" + iph.DeviceProductType + "] " + iph.DeviceName + " iOS " + iph.ProductVersion;
                setStatus("Fetching Device Information...");
                Dictionary <string, dynamic> battInfo = iph.RequestBatteryInfo();
                setStatus("Processing Information...");

                /*
                 * foreach (KeyValuePair<string, dynamic> kvp in battInfo)
                 * {
                 *  MessageBox.Show(kvp.Key+" : "+kvp.Value.ToString());
                 * }
                 */
                int  cyclecount      = (int)battInfo["CycleCount"];
                int  designcapacity  = (int)battInfo["DesignCapacity"];
                int  currentcapacity = (int)battInfo["FullChargeCapacity"];
                bool gasgauge        = battInfo["GasGaugeCapability"] == true;
                bool fullycharged    = battInfo["FullyCharged"] == true;
                bool charging        = battInfo["BatteryIsCharging"] == true;
                int  currentCharge   = (int)battInfo["BatteryCurrentCapacity"];
                label6.Text  += cyclecount.ToString();
                label7.Text  += designcapacity.ToString();
                label8.Text  += currentcapacity.ToString();
                label9.Text  += gasgauge.ToString();
                label10.Text += fullycharged.ToString();
                label11.Text += currentCharge.ToString();
                label12.Text += charging.ToString();
                setStatus("Idle.");
            }
        }
예제 #2
0
        /// <summary>
        /// iOS设备断开
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void iPhoneDisconnected(object sender, ConnectEventArgs args)
        {
            Console.WriteLine("disconnected");

            this.CurrentDevice = null;
            showDeviceInfo();

            // 弹出连接断开对话框,如果已有弹出的窗口,则忽略
            MainWindow viewMain = (MainWindow)this.View;

            viewMain.Dispatcher.Invoke(new Action(() => {
                if (App.Current.MainWindow.OwnedWindows.Count == 0)
                {
                    viewMain.openConnectDisconnect();
                }
            }));

            ////myDisconnect = new afcTest(myAFCDisconnect);
            ////this.Invoke(myDisconnect);
            //cleariPhoneInfo();
            //disconButton1.Enabled = true;
            //conToolBtn.Enabled = false;
            ////conToolBtn2.Enabled = false;
            //AfcExtractor.Enabled = false;
            ////iPhoneInterface = new iPhone(null,null);
        }
예제 #3
0
 internal void Connected(object sender, ConnectEventArgs e)
 {
     if (OnConnect != null)
     {
         OnConnect(sender, e);
     }
 }
예제 #4
0
        /// <summary>
        /// 自动获取B站动态
        /// </summary>
        /// <param name="connectEventArgs">连接事件参数</param>
        public static async void BiliUpdateCheck(ConnectEventArgs connectEventArgs)
        {
            //读取配置文件
            ConfigManager.TryGetUserConfig(connectEventArgs.LoginUid, out var loadedConfig);
            ModuleSwitch             moduleEnable  = loadedConfig.ModuleSwitch;
            List <GroupSubscription> Subscriptions = loadedConfig.SubscriptionConfig.GroupsConfig;
            //数据库
            SubscriptionDBHelper dbHelper = new(connectEventArgs.LoginUid);

            //检查模块是否启用
            if (!moduleEnable.Bili_Subscription)
            {
                return;
            }
            foreach (var subscription in Subscriptions)
            {
                //臭DD的订阅
                foreach (var biliUser in subscription.SubscriptionId)
                {
                    await GetDynamic(connectEventArgs.SoraApi, biliUser, subscription.GroupId, dbHelper);
                }

                //直播动态订阅
                foreach (var biliUser in subscription.LiveSubscriptionId)
                {
                    await GetLiveStatus(connectEventArgs.SoraApi, biliUser, subscription.GroupId, dbHelper);
                }
            }
        }
예제 #5
0
        private void HandleConnectionFailed(object sender, ConnectEventArgs e)
        {
            IPEndPoint localpPoint = e.CurrentTcpClient.Client.LocalEndPoint as IPEndPoint;
            IPEndPoint remotePoint = e.CurrentTcpClient.Client.RemoteEndPoint as IPEndPoint;

            Console.WriteLine($"连接失败:{localpPoint.Address}:{localpPoint.Port} X {remotePoint.Address}:{remotePoint.Port}");
        }
예제 #6
0
 void phone_Connect(object sender, ConnectEventArgs args)
 {
     System.Diagnostics.Trace.WriteLine(phone.DeviceName);
     System.Diagnostics.Trace.WriteLine(phone.DeviceType);
     System.Diagnostics.Trace.WriteLine(phone.DeviceVersion);
     System.Diagnostics.Trace.WriteLine(phone.IsJailbreak);
 }
예제 #7
0
        /// <summary>
        /// 初始化处理
        /// </summary>
        internal static ValueTask Initalization(object sender, ConnectEventArgs connectEvent)
        {
            ConsoleLog.Info("AntiRain初始化", "与onebot客户端连接成功,初始化资源...");
            //初始化配置文件
            ConsoleLog.Info("AntiRain初始化", $"初始化用户[{connectEvent.LoginUid}]配置");
            Config config = new Config(connectEvent.LoginUid);

            config.UserConfigFileInit();
            config.LoadUserConfig(out UserConfig userConfig, false);


            //在控制台显示启用模块
            ConsoleLog.Info("已启用的模块",
                            $"\n{userConfig.ModuleSwitch}");
            //显示代理信息
            if (userConfig.ModuleSwitch.Hso && !string.IsNullOrEmpty(userConfig.HsoConfig.PximyProxy))
            {
                ConsoleLog.Debug("Hso Proxy", userConfig.HsoConfig.PximyProxy);
            }

            //初始化数据库
            DatabaseInit.Init(connectEvent);

            //初始化定时器线程
            if (userConfig.ModuleSwitch.Bili_Subscription)
            {
                ConsoleLog.Debug("Timer Init", $"flash span = {userConfig.SubscriptionConfig.FlashTime}");
                TimerEventParse.TimerAdd(connectEvent, userConfig.SubscriptionConfig.FlashTime);
            }

            return(ValueTask.CompletedTask);
        }
예제 #8
0
        public static async ValueTask <(Socket, Stream)> ConnectAsync(string host, int port, CancellationToken cancellationToken)
        {
            // Rather than creating a new Socket and calling ConnectAsync on it, we use the static
            // Socket.ConnectAsync with a SocketAsyncEventArgs, as we can then use Socket.CancelConnectAsync
            // to cancel it if needed. Rent or allocate one.
            ConnectEventArgs saea;

            if (!s_connectEventArgs.TryDequeue(out saea))
            {
                saea = new ConnectEventArgs();
            }

            try
            {
                saea.Initialize(cancellationToken);

                // Configure which server to which to connect.
                saea.RemoteEndPoint = IPAddress.TryParse(host, out IPAddress address) ?
                                      (EndPoint) new IPEndPoint(address, port) :
                                      new DnsEndPoint(host, port);

                // Initiate the connection.
                if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, saea))
                {
                    // Connect completing asynchronously. Enable it to be canceled and wait for it.
                    using (cancellationToken.Register(s => Socket.CancelConnectAsync((SocketAsyncEventArgs)s), saea))
                    {
                        await saea.Builder.Task.ConfigureAwait(false);
                    }
                }
                else if (saea.SocketError != SocketError.Success)
                {
                    // Connect completed synchronously but unsuccessfully.
                    throw new SocketException((int)saea.SocketError);
                }

                Debug.Assert(saea.SocketError == SocketError.Success, $"Expected Success, got {saea.SocketError}.");
                Debug.Assert(saea.ConnectSocket != null, "Expected non-null socket");

                // Configure the socket and return a stream for it.
                Socket socket = saea.ConnectSocket;
                socket.NoDelay = true;
                return(socket, new NetworkStream(socket, ownsSocket: true));
            }
            catch (Exception error)
            {
                throw CancellationHelper.ShouldWrapInOperationCanceledException(error, cancellationToken) ?
                      CancellationHelper.CreateOperationCanceledException(error, cancellationToken) :
                      new HttpRequestException(error.Message, error);
            }
            finally
            {
                // Pool the event args, or if the pool is full, dispose of it.
                saea.Clear();
                if (!s_connectEventArgs.TryEnqueue(saea))
                {
                    saea.Dispose();
                }
            }
        }
예제 #9
0
 public void ClientConnected(object sender, ConnectEventArgs e)
 {
     if (OnClientConnect != null)
     {
         OnClientConnect(sender, e);
     }
 }
예제 #10
0
 private void OnMyoConnect(object sender, ConnectEventArgs e)
 {
     if (e.Status == "Success")
     {
         Dispatcher.Invoke(() =>
         {
             if (isMyoExists == true)
             {
                 for (int i = 0; i < addedDevices.Count; i++)
                 {
                     if (addedDevices[i].Type == "Myo")
                     {
                         StartTransmission(i, "Transmitting");
                     }
                 }
             }
             else
             {
                 var myoManager         = (MyoManager)sender;
                 myoManager.CurrentTick = Tick;
                 addedDevices.Add(myoManager);
                 listDevices.ItemsSource = addedDevices;
                 listDevices.Items.Refresh();
             }
             isMyoExists = true;
         });
         //myoManager.BeginReading();
     }
     else
     {
         Console.WriteLine(e.Message);
     }
 }
예제 #11
0
        public override void Execute(object parameter)
        {
            if (parameter == null)
            {
                return;
            }

            var para = (QuickConnectEventArgs)parameter;

            if (string.IsNullOrEmpty(para.Text) || para.Key == null)
            {
                return;
            }

            //Was the return-Key pressed?
            if (para.Key == Key.Enter)
            {
                //Create and get new QuickConnect-Connection
                var qcItem = QuickConnect.DoQuickConnect(para.Text, (para.SelectedProtocol == null ? "" : para.SelectedProtocol.GetProtocolIdentifer()));

                //Open connection
                var evArgs = new ConnectEventArgs();
                evArgs.ConnectionItem = qcItem;
                OnConnectEvent(evArgs);

                //Refresh ConnectionTreeView
                var evArgs2 = new ReloadConnectionListEventArgs();
                evArgs2.AddedConnection = qcItem;
                OnReloadConnectionList(evArgs2);
            }
        }
        private void OnDisconnect(object sender, ConnectEventArgs e)
        {
            RegisteredGames.RemoveGameMastersGames(e.Handler);


            // if it was a player, tell gm about it
            try
            {
                ulong playerId = Clients.First(pair => pair.Value == e.Handler).Key;
                ConsoleDebug.Message($"ID: {playerId}");



                IEnumerable <IGame> abandonedGames = RegisteredGames
                                                     .Where(game => game.Players.Any(player => player.Id == playerId));
                foreach (var game in abandonedGames)
                {
                    ConsoleDebug.Message($"Informing game master of game {game.Id} about disconnected player, id: {playerId}");
                    InformGameMasterAboutDisconnectedPlayer(game.GameMaster, playerId);

                    // remove player id occurrence
                    game.Players.Remove(game.Players.First(player => playerId == player.Id));
                }
            }
            catch (Exception exception)
            {
                // ignore: it was not a player
                Console.WriteLine(exception);
            }
        }
예제 #13
0
        private void HandleConnectionFailed(object sender, ConnectEventArgs e)
        {
            VncServerSession            session     = sender as VncServerSession;
            Dictionary <string, string> connectInfo = session.UserData as Dictionary <string, string>;

            OnAddLogEvent($"连接失败:{connectInfo["LoalIp"]}:{connectInfo["LocalpPort"]} X {connectInfo["RemoteIp"]}:{connectInfo["RemotePort"]}");
        }
예제 #14
0
 private void Iph_Connect(object sender, ConnectEventArgs args)
 {
     label2.Text     = "Connected to Device.";
     button2.Enabled = true;
     usbPaired       = false;
     button3.Enabled = false;
 }
        /// <summary>
        /// 初始化处理
        /// </summary>
        internal static ValueTask Initalization(string _, ConnectEventArgs connectEvent)
        {
            Log.Info("AntiRain初始化", "与onebot客户端连接成功,初始化资源...");
            //初始化配置文件
            Log.Info("AntiRain初始化", $"初始化用户[{connectEvent.LoginUid}]的配置");
            if (!ConfigManager.UserConfigFileInit(connectEvent.LoginUid) ||
                !ConfigManager.TryGetUserConfig(connectEvent.LoginUid, out var userConfig))
            {
                Log.Fatal("AntiRain初始化", "无法获取用户配置文件");
                Environment.Exit(-1);
                return(ValueTask.CompletedTask);
            }

            //在控制台显示启用模块
            Log.Info("已启用的模块",
                     $"\n{userConfig.ModuleSwitch}");
            //显示代理信息
            if (userConfig.ModuleSwitch.Hso && !string.IsNullOrEmpty(userConfig.HsoConfig.PximyProxy))
            {
                Log.Debug("Hso Proxy", userConfig.HsoConfig.PximyProxy);
            }

            //初始化数据库
            DatabaseInit.UserDataInit(connectEvent);

            //初始化定时器线程
            if (userConfig.ModuleSwitch.Bili_Subscription)
            {
                SubscriptionTimer.TimerEventAdd(connectEvent);
            }

            return(ValueTask.CompletedTask);
        }
예제 #16
0
        private void OnConnect(ConnectEventArgs args)
        {
            var    player = new TSPlayer(args.Who);
            string host   = SQL.GetHostFromCache(player.IP);

            if (host == null)
            {
                try
                {
                    System.Net.IPHostEntry hostname = System.Net.Dns.GetHostByAddress(player.IP);
                    host = hostname.HostName;
                }
                catch (Exception e)
                {
                    host = player.IP;
                }
                SQL.InsertCacheEntry(host, player.IP);
            }
            SQL.HostBan ban = SQL.GetBanByHost(host);
            if (ban != null)
            {
                TShock.Utils.ForceKick(player, string.Format("Banned for: {0}.", ban.Reason), true, false);
                args.Handled = true;
                return;
            }
        }
예제 #17
0
        /// <summary>
        /// 自动获取B站动态
        /// </summary>
        /// <param name="connectEventArgs">连接事件参数</param>
        public static async void BiliUpdateCheck(ConnectEventArgs connectEventArgs)
        {
            //读取配置文件
            Config config = new Config(connectEventArgs.LoginUid);

            config.LoadUserConfig(out UserConfig loadedConfig);
            ModuleSwitch             moduleEnable  = loadedConfig.ModuleSwitch;
            List <GroupSubscription> Subscriptions = loadedConfig.SubscriptionConfig.GroupsConfig;
            //数据库
            SubscriptionDBHelper dbHelper = new SubscriptionDBHelper(connectEventArgs.LoginUid);

            //检查模块是否启用
            if (!moduleEnable.Bili_Subscription)
            {
                return;
            }
            foreach (GroupSubscription subscription in Subscriptions)
            {
                //PCR动态订阅
                if (subscription.PCR_Subscription)
                {
                    await GetDynamic(connectEventArgs.SoraApi, 353840826, subscription.GroupId, dbHelper);
                }
                //臭DD的订阅
                foreach (long biliUser in subscription.SubscriptionId)
                {
                    await GetDynamic(connectEventArgs.SoraApi, biliUser, subscription.GroupId, dbHelper);
                }
            }
        }
예제 #18
0
        /// <summary>
        /// This method is invoked when a new inbound socket hits our server.  We will create a new
        /// SMPP session object to manage the socket and begin communicating with the ESME session.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected void OnStartSession(object sender, SocketEventArgs args)
        {
            ConnectEventArgs connEv = (ConnectEventArgs)args;
            SocketClient     scNew  = connEv.Client;

            // Create a new SMPP session to manage this connection.
            SmscSession newSession = new SmscSession(this, scNew, systemid_);

            // Back-link the session
            scNew.Tag = newSession;

            // Notify anyone who wants to know
            SmppConnectEventArgs sce = new SmppConnectEventArgs(scNew.Address, newSession);

            if (OnNewSession != null)
            {
                OnNewSession(this, sce);
            }
            if (!sce.AllowConnection)
            {
                scNew.Close(true);
            }
            else
            {
                scNew.OnEndSession += OnEndClientSession;
                lock (clients_)
                {
                    clients_.Add(newSession);
                }
            }
        }
예제 #19
0
 public static void BroadcastConnectEvent(object sender, ConnectEventArgs args)
 {
     if (mConnectEventHandler != null)
     {
         mConnectEventHandler(sender, args);
     }
 }
예제 #20
0
        /// <summary>
        /// 启动连接服务器的事件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void OnTcpServerConnecting(Object sender, ConnectEventArgs args)
        {
            // 信号量复位,堵塞主流程
            connectDone.Reset();

            string info = string.Empty;

            // 控件的跨线程调用处理
            if (cbxGroupNo.InvokeRequired)
            {
                // 当一个控件的InvokeRequired属性值为真时,说明有一个创建它以外的线程想访问它
                Action actionDelegate = () =>
                {
                    info = string.Format("开始连接{0}区服务器:IP地址{1}  端口号{2}", cbxGroupNo.Text,
                                         (args.RemoteEndPoint as IPEndPoint).Address.ToString(), (args.RemoteEndPoint as IPEndPoint).Port);
                };

                this.cbxGroupNo.Invoke(actionDelegate);
            }
            else
            {
                info = string.Format("开始连接{0}区服务器:IP地址{1}  端口号{2}", cbxGroupNo.Text,
                                     (args.RemoteEndPoint as IPEndPoint).Address.ToString(), (args.RemoteEndPoint as IPEndPoint).Port);
            }

            // 更新信息栏
            UpdateClipBoardInfo(info);
        }
예제 #21
0
 public void OnConnectEvent(object sender, ConnectEventArgs args)
 {
     if (ConnectEvent != null)
     {
         ConnectEvent(sender, args);
     }
 }
예제 #22
0
 /// <summary>
 /// Dispatches the ConnectComplete event if any targets have registered.
 /// </summary>
 /// <param name="e">A ConnectEventArgs object with information about the remote framebuffer's geometry.</param>
 /// <exception cref="System.InvalidOperationException">Thrown if the RemoteDesktop control is not in the Connected state.</exception>
 protected void OnConnectComplete(ConnectEventArgs e)
 {
     if (ConnectComplete != null)
     {
         ConnectComplete(this, e);
     }
 }
예제 #23
0
        private void _rd_ConnectComplete(object sender, ConnectEventArgs e)
        {
            ClientSize = new Size(e.DesktopWidth, e.DesktopHeight);
            Text       = e.DesktopName;

            _rd.Focus();
        }
예제 #24
0
 protected void OnPlayerConnect(ConnectEventArgs args)
 {
     if (PlayerConnect != null)
     {
         PlayerConnect(args);
     }
 }
예제 #25
0
 /// <summary>
 /// 添加新的计时器
 /// </summary>
 /// <param name="connectEventArgs">ConnectEventArgs</param>
 /// <param name="updateSpan">定时时长</param>
 internal static void TimerAdd(ConnectEventArgs connectEventArgs, uint updateSpan)
 {
     Timers.Add(connectEventArgs.LoginUid,
                new Timer(SubscriptionEvent,                        //事件处理
                          connectEventArgs,                         //初始化数据
                          new TimeSpan(0),                          //即刻执行
                          new TimeSpan(0, 0, 0, (int)updateSpan))); //设置刷新间隔
 }
예제 #26
0
 protected static void OnConnect(ConnectEventArgs args)
 {
     MetaModEngine.SetResult(MetaResult.Handled);
     if (Connect != null)
     {
         Connect(args);
     }
 }
예제 #27
0
 private void CommandDispatcher_ConnectSucceded(object sender, ConnectEventArgs e)
 {
     if (e.Connected)
     {
         CommandDispatcher.OnAuthOver += CommandDispatcherOnOnAuthOver;
         CommandDispatcher.SendAuthMessage("light", "hjok123");
     }
 }
예제 #28
0
 private void Iph_Disconnect(object sender, ConnectEventArgs args)
 {
     label2.Text     = "No Device Detected.";
     button1.Enabled = false;
     button2.Enabled = false;
     usbPaired       = false;
     button3.Enabled = false;
 }
예제 #29
0
 static void OnConnect(object sender, ConnectEventArgs args)
 {
     Console.Title = (sender as NetClient).ClientKey + " " + mTitle;
     mTitle       += ". ";
     if (mTitle.Length > 10)
     {
         mTitle = string.Empty;
     }
 }
        private async void ConnPane_OnConnected(object sender, ConnectEventArgs e)
        {
            await GetCrmData();

            if (!ConfigFile.ConfigFileExists(_dte.Solution.FullName))
            {
                ConfigFile.CreateConfigFile(ConnPane.OrganizationId, ConnPane.SelectedProject.UniqueName, _dte.Solution.FullName);
            }
        }
예제 #31
0
파일: IrcClient.cs 프로젝트: hapm/IrcShark
        /// <summary>
        /// Connects to the irc server addressed by <see cref="ServerAddress"/>.
        /// </summary>
        public void Connect()
        {
            IAsyncResult test;
            if (ServerAddress == null)
                return;
            try
            {
                test = client.BeginConnect(ServerAddress.Address, ServerAddress.Port, null, this);
                test.AsyncWaitHandle.WaitOne();
                if (IsConnected)
                {
                    ConnectEventArgs args = new ConnectEventArgs(this);
                    if (Connected != null)
                        Connected(this, new ConnectEventArgs(this));

                    inReader = new StreamReader(client.GetStream(), System.Text.Encoding.Default);
                    outWriter = new StreamWriter(client.GetStream(), System.Text.Encoding.Default);

                    readerThread = new Thread(new ThreadStart(ReadLines));
                    readerThread.Start();

                    if (!args.Handled)
                    {
                        SendLine("NICK " + CurrentNick);
                        SendLine("USER " + Username + " \"\" \"" + ServerAddress.Address.ToString() + "\" :" + Username);
                    }
                }
                else
                {
                    OnError(new ErrorEventArgs(this, "Couldn't connect to given address"));
                }
            }
            catch (Exception ex)
            {
                OnError(new ErrorEventArgs(this, "Couldn't connect to given address", ex));
            }
        }
예제 #32
0
파일: Player.cs 프로젝트: txdv/sharpmod
        internal static bool OnConnect(IntPtr entity, string name, string address, string reject_reason)
        {
            Player player = Player.GetPlayer(entity);
            player.Name = name;
            string[] addressinformation = address.Split(':');
            player.IPAddress = IPAddress.Parse(addressinformation[0]);
            player.Port = Convert.ToInt32(addressinformation[1]);

            if (player.PendingAuth) {
                pendingAuthPlayers.Add(player);
            } else {
                Player.OnAuthorize(player);
            }

            ConnectEventArgs connectEventArgs = new ConnectEventArgs(player, reject_reason);
            OnConnect(connectEventArgs);
            player.OnPlayerConnect(connectEventArgs);
            return true;
        }
예제 #33
0
파일: Player.cs 프로젝트: txdv/sharpmod
 protected static void OnConnect(ConnectEventArgs args)
 {
     MetaModEngine.SetResult(MetaResult.Handled);
     if (Connect != null) {
         Connect(args);
     }
 }
예제 #34
0
파일: Player.cs 프로젝트: txdv/sharpmod
 protected void OnPlayerConnect(ConnectEventArgs args)
 {
     if (PlayerConnect != null) {
         PlayerConnect(args);
     }
 }
 void OnConnectHandler(ConnectEventSource source, ConnectEventArgs e)
 {
     Logger.Debug("[GenericTransportAgent] SmtpReceiveAgent - OnConnect fired...");
     _config.SmtpReceiveAgentConfig.OnConnect.ToList().ForEach(x => { try { x.Execute(); } catch (Exception ex) { Logger.Error(ex, @"Error executing ""OnConnect"""); } });
 }