Example #1
0
        private void OnInfo(AMCPEventArgs e)
        {
            var infos = e.Data
                        .Select(DataParser.ParseChannelInfo)
                        .Where(x => x != null).ToList();

            InfoReceived?.Invoke(this, new InfoEventArgs(infos));
        }
Example #2
0
 private void InfoReceivedInvokeCallback(IAsyncResult ar)
 {
     try
     {
         InfoReceived?.EndInvoke(ar);
     }
     catch {
         //"can not access disposed object: FrmMain"
     }
 }
 protected void SendInfo(string message, InfoType type)
 {
     InfoReceived?.Invoke(this, new InfoData {
         Comment = message, Type = type
     });
 }
 protected virtual void OnInfoReceived()
 {
     InfoReceived?.Invoke(this, EventArgs.Empty);
 }
 private void SendSystemInfo(string message, InfoType type)
 {
     InfoReceived?.Invoke(this, new InfoData {
         Comment = message, Type = type
     });
 }
Example #6
0
        private static void accSess_OnUserRequestPropertyResult(AccSession session, IAccUser user, AccUserProp Property, int transId, AccResult hr, object propertyValue)
        {
            //if its the idle time, raise the event if necessary
            if (Property == AccUserProp.AccUserProp_IdleTime)
            {
                //if the user's idle time is > 0 then raise idle event
                if ((int)propertyValue > 0)
                {
                    BuddyWentIdle(user.Name, GetUsersGroupsNames(user));
                }
            }
            else if (Property == AccUserProp.AccUserProp_Profile)
            {
                //profile is actually an IM object
                IAccIm im = (IAccIm)propertyValue;

                //dequeue the request
                Actions.QueueOfRequests.Dequeue();

                //check that this is the last queued request
                if (Actions.QueueOfRequests.Count < 1)
                {
                    //add the profile to the return var
                    strReturnRequest += im.GetConvertedText(MIME_TYPE);

                    //invoke info received event
                    if (InfoReceived != null)
                    {
                        InfoReceived.Invoke(user.Name, strReturnRequest);
                    }
                }
                else
                {
                    //add the profile to the return
                    strReturnRequest = im.GetConvertedText(MIME_TYPE);
                }
            }
            else if (Property == AccUserProp.AccUserProp_AwayMessage)
            {
                //away message is actually an IM object
                IAccIm im = (IAccIm)propertyValue;

                //dequeue the request
                Actions.QueueOfRequests.Dequeue();

                //check the request count
                if (Actions.QueueOfRequests.Count < 1)
                {
                    //put this text at the beginning of the request
                    strReturnRequest = im.GetConvertedText(MIME_TYPE) + strReturnRequest;

                    //invoke away message reveived event
                    if (AwayMessageReceived != null)
                    {
                        AwayMessageReceived.Invoke(user.Name, strReturnRequest);
                    }
                }
                else
                {
                    //set the return request var as the decoded string
                    strReturnRequest = im.GetConvertedText(MIME_TYPE);
                }
            }
        }
Example #7
0
 private void Receive(User user, Message message)
 {
     InfoReceived?.Invoke(this, new ChatEventArgs {
         User = user, Message = message
     });
 }
Example #8
0
 void InfoResponse(InfoResponse status)
 {
     //fire the event
     InfoReceived?.Invoke(this, new DataEventArg <InfoResponse>(status));
 }
Example #9
0
        /// <summary>
        ///    Listens for data from server. The Main processing thread.
        /// </summary>
        private void ListenForData()
        {
            while (IsConnected)
            {
                var readingData = new byte[0x1000];
                ReadData = new BufferChunk(readingData);
                var numberOfBytesRead = 0;
                fNetworkStream = Sender.GetStream();

                try {
                    while (fNetworkStream.DataAvailable)
                    {
                        var len = fNetworkStream.Read(readingData, 0, readingData.Length);
                        numberOfBytesRead += len;
                        ReadData          += readingData;
                    }
                } catch {
                    //ignore errors
                }

                if (numberOfBytesRead < PacketHeader.Length)
                {
                    Thread.Sleep(200);
                    continue;
                }

                Header = ReadData.NextPacketHeader();

                switch ((EPacketType)Header.type)
                {
                case EPacketType.Info:
                    if (InfoReceived != null)
                    {
                        InfoReceived.Invoke();
                    }

                    break;

                case EPacketType.Error:
                    if (ErrorReceived != null)
                    {
                        ErrorReceived.Invoke();
                    }

                    break;

                case EPacketType.Data:
                {
                    var cmd = (EDataCommand)Header.value;

                    if (cmd == EDataCommand.STATE)
                    {
                        StateData = ReadData.StateData();
                        ProcessState(StateData);
                    }

                    ProcessData(ReadData, numberOfBytesRead);
                    break;
                }
                }

                Thread.Sleep(200);
            }

            Disconnect();
        }
Example #10
0
 private void PrintError(string format, params object[] args)
 {
     InfoReceived?.BeginInvoke(TAG, string.Format(format, args), EventType.Error, InfoReceivedInvokeCallback, null);
 }
 protected virtual void OnInfoReceived(MessageEventArgs e)
 {
     InfoReceived?.Invoke(this, e);
 }