Пример #1
0
        public static Task <AVLiveQuery <T> > CreateAsync <T>(this AVQuery <T> query, string sessionToken = "", CancellationToken cancellationToken = default(CancellationToken)) where T : AVObject
        {
            Dictionary <string, object> strs = new Dictionary <string, object>()
            {
                { "where", query.Condition },
                { "className", query.GetClassName <T>() },
                { "sessionToken", sessionToken }
            };

            var command = new AVCommand("LiveQuery/subscribe",
                                        "POST",
                                        sessionToken: sessionToken,
                                        data: strs);

            return(AVPlugins.Instance.CommandRunner.RunCommandAsync(command).OnSuccess(t =>
            {
                var subscriptionId = t.Result.Item2["id"] as string;
                var queryId = t.Result.Item2["query_id"] as string;
                var rtn = new AVLiveQuery <T>(subscriptionId)
                {
                    Query = query,
                    QueryId = queryId
                };
                return rtn;
            }));
        }
Пример #2
0
        public Task TestRunCommandWithArrayResult()
        {
            var mockHttpClient = new Mock <IHttpClient>();
            var mockInstallationIdController = new Mock <IInstallationIdController>();
            var fakeResponse = Task <Tuple <HttpStatusCode, string> > .FromResult(new Tuple <HttpStatusCode, string>(HttpStatusCode.OK, "[]"));

            mockHttpClient.Setup(obj => obj.ExecuteAsync(It.IsAny <HttpRequest>(),
                                                         It.IsAny <IProgress <AVUploadProgressEventArgs> >(),
                                                         It.IsAny <IProgress <AVDownloadProgressEventArgs> >(),
                                                         It.IsAny <CancellationToken>())).Returns(fakeResponse);

            mockInstallationIdController.Setup(i => i.GetAsync()).Returns(Task.FromResult <Guid?>(null));

            AVCommandRunner commandRunner = new AVCommandRunner(mockHttpClient.Object, mockInstallationIdController.Object);
            var             command       = new AVCommand("endpoint", method: "GET", data: null);

            return(commandRunner.RunCommandAsync(command).ContinueWith(t =>
            {
                Assert.False(t.IsFaulted);
                Assert.False(t.IsCanceled);
                Assert.IsInstanceOf <IDictionary <string, object> >(t.Result.Item2);
                Assert.AreEqual(1, t.Result.Item2.Count);
                Assert.True(t.Result.Item2.ContainsKey("results"));
                Assert.IsInstanceOf <IList <object> >(t.Result.Item2["results"]);
            }));
        }
Пример #3
0
        public Task TestRunCommandWithInvalidString()
        {
            var mockHttpClient = new Mock <IHttpClient>();
            var mockInstallationIdController = new Mock <IInstallationIdController>();
            var fakeResponse = Task <Tuple <HttpStatusCode, string> > .FromResult(new Tuple <HttpStatusCode, string>(HttpStatusCode.OK, "invalid"));

            mockHttpClient.Setup(obj => obj.ExecuteAsync(It.IsAny <HttpRequest>(),
                                                         It.IsAny <IProgress <AVUploadProgressEventArgs> >(),
                                                         It.IsAny <IProgress <AVDownloadProgressEventArgs> >(),
                                                         It.IsAny <CancellationToken>())).Returns(fakeResponse);

            mockInstallationIdController.Setup(i => i.GetAsync()).Returns(Task.FromResult <Guid?>(null));

            AVCommandRunner commandRunner = new AVCommandRunner(mockHttpClient.Object, mockInstallationIdController.Object);
            var             command       = new AVCommand("endpoint", method: "GET", data: null);

            return(commandRunner.RunCommandAsync(command).ContinueWith(t =>
            {
                Assert.True(t.IsFaulted);
                Assert.False(t.IsCanceled);
                Assert.IsInstanceOf <AVException>(t.Exception.InnerException);
                var parseException = t.Exception.InnerException as AVException;
                Assert.AreEqual(AVException.ErrorCode.OtherCause, parseException.Code);
            }));
        }
Пример #4
0
        /// <summary>
        /// 请求发送验证码。
        /// </summary>
        /// <returns>是否发送成功。</returns>
        /// <param name="mobilePhoneNumber">手机号。</param>
        /// <param name="name">应用名称。</param>
        /// <param name="op">进行的操作名称。</param>
        /// <param name="ttl">验证码失效时间。</param>
        /// <param name="cancellationToken">Cancellation token。</param>
        public static Task <bool> RequestSMSCodeAsync(string mobilePhoneNumber, string name, string op, int ttl = 10, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (string.IsNullOrEmpty(mobilePhoneNumber))
            {
                throw new AVException(AVException.ErrorCode.MobilePhoneInvalid, "Moblie Phone number is invalid.", null);
            }

            Dictionary <string, object> strs = new Dictionary <string, object>()
            {
                { "mobilePhoneNumber", mobilePhoneNumber },
            };

            if (!string.IsNullOrEmpty(name))
            {
                strs.Add("name", name);
            }
            if (!string.IsNullOrEmpty(op))
            {
                strs.Add("op", op);
            }
            if (ttl > 0)
            {
                strs.Add("TTL", ttl);
            }
            var command = new AVCommand("requestSmsCode",
                                        method: "POST",
                                        sessionToken: null,
                                        data: strs);

            return(AVPlugins.Instance.CommandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).ContinueWith(t =>
            {
                return AVClient.IsSuccessStatusCode(t.Result.Item1);
            }));
        }
Пример #5
0
        internal static Task <Tuple <HttpStatusCode, IDictionary <string, object> > > RequestAsync(string method, Uri relativeUri, string sessionToken, IDictionary <string, object> data, CancellationToken cancellationToken)
        {
            var command = new AVCommand(relativeUri.ToString(),
                                        method: method,
                                        sessionToken: sessionToken,
                                        data: data);

            return(AVClient.AVCommandRunner.RunCommandAsync(command, cancellationToken: cancellationToken));
        }
Пример #6
0
        public Task SendPushNotificationAsync(IAVState state, CancellationToken cancellationToken)
        {
            return(currentUserController.GetCurrentSessionTokenAsync(cancellationToken).OnSuccess(sessionTokenTask => {
                var command = new AVCommand("push",
                                            method: "POST",
                                            sessionToken: sessionTokenTask.Result,
                                            data: AVPushEncoder.Instance.Encode(state));

                return commandRunner.RunCommandAsync(command, cancellationToken: cancellationToken);
            }).Unwrap());
        }
Пример #7
0
        /// <summary>
        /// 验证是否是有效短信验证码。
        /// </summary>
        /// <returns>是否验证通过。</returns>
        /// <param name="code">验证码。</param>
        /// <param name="mobilePhoneNumber">手机号</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        public static Task <bool> VerifySmsCodeAsync(string code, string mobilePhoneNumber, CancellationToken cancellationToken)
        {
            var command = new AVCommand("verifySmsCode/" + code.Trim() + "?mobilePhoneNumber=" + mobilePhoneNumber.Trim(),
                                        method: "POST",
                                        sessionToken: null,
                                        data: null);

            return(AVPlugins.Instance.CommandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).ContinueWith(t =>
            {
                return AVClient.IsSuccessStatusCode(t.Result.Item1);
            }));
        }
Пример #8
0
        public Task <bool> SendAsync(IDictionary <string, object> analyticsData, string sessionToken, CancellationToken cancellationToken)
        {
            var command = new AVCommand("stats/collect",
                                        method: "POST",
                                        sessionToken: sessionToken,
                                        data: analyticsData);

            return(commandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).OnSuccess(t =>
            {
                return t.Result.Item1 == System.Net.HttpStatusCode.OK;
            }));
        }
Пример #9
0
        public Task <IDictionary <string, object> > GetPolicyAsync(string sessionToken, CancellationToken cancellationToken)
        {
            var command = new AVCommand(string.Format("statistics/apps/{0}/sendPolicy", AVClient.CurrentConfiguration.ApplicationId),
                                        method: "GET",
                                        sessionToken: sessionToken,
                                        data: null);

            return(commandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).OnSuccess(t =>
            {
                return t.Result.Item2;
            }));
        }
Пример #10
0
        /// <summary>
        /// Get the custom cloud parameters, you can set them at console https://leancloud.cn/dashboard/devcomponent.html?appid={your_app_Id}#/component/custom_param
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public static Task <IDictionary <string, object> > GetCustomParametersAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            var command = new AVCommand(string.Format("statistics/apps/{0}/sendPolicy", AVClient.CurrentConfiguration.ApplicationId),
                                        method: "GET",
                                        sessionToken: null,
                                        data: null);

            return(AVPlugins.Instance.CommandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).OnSuccess(t =>
            {
                var settings = t.Result.Item2;
                var CloudParameters = settings["parameters"] as IDictionary <string, object>;
                return CloudParameters;
            }));
        }
Пример #11
0
        /// <summary>
        /// Requests the login SMS code asynchronous.
        /// </summary>
        /// <param name="mobilePhoneNumber">The mobile phone number.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns></returns>
        public static Task <bool> RequestLoginSmsCodeAsync(string mobilePhoneNumber, CancellationToken cancellationToken)
        {
            Dictionary <string, object> strs = new Dictionary <string, object>()
            {
                { "mobilePhoneNumber", mobilePhoneNumber }
            };
            var command = new AVCommand("/requestLoginSmsCode",
                                        method: "POST",
                                        sessionToken: CurrentSessionToken,
                                        data: null);

            return(AVClient.RequestAsync("POST", "/requestLoginSmsCode", null, strs, cancellationToken).OnSuccess <Tuple <HttpStatusCode, IDictionary <string, object> >, bool>((Task <Tuple <HttpStatusCode, IDictionary <string, object> > > t) => {
                return AVClient.IsSuccessStatusCode(t.Result.Item1);
            }));
        }
Пример #12
0
        /// <summary>
        /// Get a captcha image.
        /// </summary>
        /// <param name="width">captcha image width.</param>
        /// <param name="height">captcha image height.</param>
        /// <param name="cancellationToken">CancellationToken.</param>
        /// <returns>an instance of Captcha.</returns>
        public static Task <Captcha> RequestCaptchaAsync(int width = 85, int height = 30, CancellationToken cancellationToken = default(CancellationToken))
        {
            var path    = String.Format("requestCaptcha?width={0}&height={1}", width, height);
            var command = new AVCommand(path, method: "GET", sessionToken: null, data: null);

            return(AVPlugins.Instance.CommandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).OnSuccess(t =>
            {
                var decoded = AVDecoder.Instance.Decode(t.Result.Item2) as IDictionary <string, object>;
                return new Captcha()
                {
                    Token = decoded["captcha_token"] as string,
                    Url = decoded["captcha_url"] as string,
                };
            }));
        }
Пример #13
0
        /// <summary>
        /// 获取暂态对话(聊天室)在线人数,依赖缓存,并不一定 100% 与真实数据一致。
        /// </summary>
        /// <param name="chatroomId"></param>
        /// <returns></returns>
        public Task <int> CountOnlineClientsAsync(string chatroomId)
        {
            var command = new AVCommand(relativeUri: "rtm/transient_group/onlines?gid=" + chatroomId, method: "GET",
                                        sessionToken: null,
                                        headers: null,
                                        data: null);

            return(AVPlugins.Instance.CommandRunner.RunCommandAsync(command).OnSuccess(t =>
            {
                var result = t.Result.Item2;
                if (result.ContainsKey("result"))
                {
                    return int.Parse(result["result"].ToString());
                }
                return -1;
            }));
        }
Пример #14
0
        /// <summary>
        /// Verify the user's input of catpcha.
        /// </summary>
        /// <param name="token">The captcha's token, from server.</param>
        /// <param name="code">User's input of this captcha.</param>
        /// <param name="cancellationToken">CancellationToken.</param>
        /// <returns></returns>
        public static Task <string> VerifyCaptchaAsync(string code, string token, CancellationToken cancellationToken = default(CancellationToken))
        {
            var data = new Dictionary <string, object>
            {
                { "captcha_token", token },
                { "captcha_code", code },
            };
            var command = new AVCommand("verifyCaptcha", method: "POST", sessionToken: null, data: data);

            return(AVPlugins.Instance.CommandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).ContinueWith(t =>
            {
                if (!t.Result.Item2.ContainsKey("validate_token"))
                {
                    throw new KeyNotFoundException("validate_token");
                }
                return t.Result.Item2["validate_token"] as string;
            }));
        }
Пример #15
0
        /// <summary>
        /// 执行 CQL 查询
        /// </summary>
        /// <param name="cql">CQL 语句</param>
        /// <param name="cancellationToken">CancellationToken</param>
        /// <returns>返回符合条件的对象集合</returns>
        public static Task <IEnumerable <T> > DoCloudQueryAsync(string cql, CancellationToken cancellationToken)
        {
            var command = new AVCommand(string.Format("/cloudQuery?cql={0}", Uri.EscapeDataString(cql)),
                                        method: "GET",
                                        sessionToken: AVUser.CurrentSessionToken,
                                        data: null);

            return(AVClient.AVCommandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).OnSuccess(t => {
                var items = t.Result.Item2["results"] as IList <object>;
                var className = t.Result.Item2["className"].ToString();

                IEnumerable <IObjectState> states = (from item in items
                                                     select AVObjectCoder.Instance.Decode(item as IDictionary <string, object>, AVDecoder.Instance));

                return (from state in states
                        select AVObject.FromState <T>(state, className));
            }));
        }
Пример #16
0
        internal static Task <IEnumerable <T> > rebuildObjectFromCloudQueryResult(string queryString)
        {
            var command = new AVCommand(queryString,
                                        method: "GET",
                                        sessionToken: AVUser.CurrentSessionToken,
                                        data: null);

            return(AVPlugins.Instance.CommandRunner.RunCommandAsync(command, cancellationToken: CancellationToken.None).OnSuccess(t =>
            {
                var items = t.Result.Item2["results"] as IList <object>;
                var className = t.Result.Item2["className"].ToString();

                IEnumerable <IObjectState> states = (from item in items
                                                     select AVObjectCoder.Instance.Decode(item as IDictionary <string, object>, AVDecoder.Instance));

                return (from state in states
                        select AVObject.FromState <T>(state, className));
            }));
        }
Пример #17
0
        public Task <bool> Unsubscribe(string sessionToken = "")
        {
            Dictionary <string, object> strs = new Dictionary <string, object>()
            {
                { "id", Id },
                { "query_id", QueryId },
            };

            AVLiveQueryExtensions.GetCurrentSessionToken(sessionToken);
            var command = new AVCommand("LiveQuery/unsubscribe/" + Id,
                                        "POST",
                                        sessionToken: sessionToken,
                                        data: strs);

            return(AVPlugins.Instance.CommandRunner.RunCommandAsync(command).OnSuccess(t =>
            {
                return t.Result.Item1 != System.Net.HttpStatusCode.NotFound;
            }));
        }
Пример #18
0
        public Task TrackAppOpenedAsync(string pushHash,
                                        string sessionToken,
                                        CancellationToken cancellationToken)
        {
            IDictionary <string, object> data = new Dictionary <string, object> {
                { "at", DateTime.Now }
            };

            if (pushHash != null)
            {
                data["push_hash"] = pushHash;
            }

            var command = new AVCommand("events/AppOpened",
                                        method: "POST",
                                        sessionToken: sessionToken,
                                        data: PointerOrLocalIdEncoder.Instance.Encode(data) as IDictionary <string, object>);

            return(commandRunner.RunCommandAsync(command, cancellationToken: cancellationToken));
        }
Пример #19
0
        /// <summary>
        /// 发送手机短信,并指定模板以及传入模板所需的参数。
        /// Exceptions:
        ///   AVOSCloud.AVException:
        ///   手机号为空。
        /// <param name="mobilePhoneNumber"></param>
        /// <param name="template">Sms's template</param>
        /// <param name="env">Template variables env.</param>
        /// <param name="sign">Sms's sign.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns></returns>
        public static Task <bool> RequestSMSCodeAsync(
            string mobilePhoneNumber,
            string template,
            IDictionary <string, object> env,
            string sign          = "",
            string validateToken = "",
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (string.IsNullOrEmpty(mobilePhoneNumber))
            {
                throw new AVException(AVException.ErrorCode.MobilePhoneInvalid, "Moblie Phone number is invalid.", null);
            }
            Dictionary <string, object> strs = new Dictionary <string, object>()
            {
                { "mobilePhoneNumber", mobilePhoneNumber },
            };

            strs.Add("template", template);
            if (String.IsNullOrEmpty(sign))
            {
                strs.Add("sign", sign);
            }
            if (String.IsNullOrEmpty(validateToken))
            {
                strs.Add("validate_token", validateToken);
            }
            foreach (var key in env.Keys)
            {
                strs.Add(key, env[key]);
            }
            var command = new AVCommand("requestSmsCode",
                                        method: "POST",
                                        sessionToken: null,
                                        data: strs);

            return(AVPlugins.Instance.CommandRunner.RunCommandAsync(command).ContinueWith(t =>
            {
                return AVClient.IsSuccessStatusCode(t.Result.Item1);
            }));
        }
Пример #20
0
        public Task TrackEventAsync(string name,
                                    IDictionary <string, string> dimensions,
                                    string sessionToken,
                                    CancellationToken cancellationToken)
        {
            IDictionary <string, object> data = new Dictionary <string, object> {
                { "at", DateTime.Now },
                { "name", name },
            };

            if (dimensions != null)
            {
                data["dimensions"] = dimensions;
            }

            var command = new AVCommand("events/" + name,
                                        method: "POST",
                                        sessionToken: sessionToken,
                                        data: PointerOrLocalIdEncoder.Instance.Encode(data) as IDictionary <string, object>);

            return(commandRunner.RunCommandAsync(command, cancellationToken: cancellationToken));
        }
Пример #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mobilePhoneNumber"></param>
        /// <returns></returns>
        public static Task <bool> RequestVoiceCodeAsync(string mobilePhoneNumber)
        {
            if (string.IsNullOrEmpty(mobilePhoneNumber))
            {
                throw new AVException(AVException.ErrorCode.MobilePhoneInvalid, "Moblie Phone number is invalid.", null);
            }
            Dictionary <string, object> strs = new Dictionary <string, object>()
            {
                { "mobilePhoneNumber", mobilePhoneNumber },
                { "smsType", "voice" },
                { "IDD", "+86" }
            };

            var command = new AVCommand("requestSmsCode",
                                        method: "POST",
                                        sessionToken: null,
                                        data: strs);

            return(AVPlugins.Instance.CommandRunner.RunCommandAsync(command).ContinueWith(t =>
            {
                return AVClient.IsSuccessStatusCode(t.Result.Item1);
            }));
        }
Пример #22
0
        public static Task <RealtimeSignature> RequestRealtimeSignatureAsync(AVUser user, CancellationToken cancellationToken = default(CancellationToken))
        {
            var command = new AVCommand(string.Format("rtm/sign"),
                                        method: "POST",
                                        sessionToken: null,
                                        data: new Dictionary <string, object>
            {
                { "session_token", user.SessionToken },
            }
                                        );

            return(AVPlugins.Instance.CommandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).ContinueWith(t =>
            {
                var body = t.Result.Item2;
                return new RealtimeSignature()
                {
                    Nonce = body["nonce"] as string,
                    Timestamp = (long)body["timestamp"],
                    ClientId = body["client_id"] as string,
                    Signature = body["signature"] as string,
                };
            }));
        }
Пример #23
0
        /// <summary>
        /// 获取 LeanCloud 服务器的时间
        /// <remarks>
        /// 如果获取失败,将返回 DateTime.MinValue
        /// </remarks>
        /// </summary>
        /// <returns>服务器的时间</returns>
        public static Task <DateTime> GetServerDateTimeAsync()
        {
            var command = new AVCommand(relativeUri: "date",
                                        method: "GET",
                                        sessionToken: null,
                                        data: null);

            return(AVPlugins.Instance.CommandRunner.RunCommandAsync(command).ContinueWith(t =>
            {
                DateTime rtn = DateTime.MinValue;
                if (AVClient.IsSuccessStatusCode(t.Result.Item1))
                {
                    var date = AVDecoder.Instance.Decode(t.Result.Item2);
                    if (date != null)
                    {
                        if (date is DateTime)
                        {
                            rtn = (DateTime)date;
                        }
                    }
                }
                return rtn;
            }));
        }
Пример #24
0
        private void ExecuteCommand(object obj)
        {
            if (obj is byte[])
            {
                byte[] buffertemp = obj as byte[];
                if (buffertemp.Count() > 0)
                {
                    //if (BitConverter.IsLittleEndian)
                    //    Array.Reverse(buffertemp);
                    StreamType type = (StreamType)BitConverter.ToInt32(new byte[] { buffertemp[0], buffertemp[1], buffertemp[2], buffertemp[3] }, 0);

                    int command = BitConverter.ToInt32(new byte[] { buffertemp[4], buffertemp[5], buffertemp[6], buffertemp[7] }, 0);
                    switch (type)
                    {
                    case StreamType.CommandSystem:
                        SysCommand sysCommand = (SysCommand)command;
                        switch (sysCommand)
                        {
                        case SysCommand.ShutDown:
                            SysCommandManager.ShutDownS(30);
                            break;

                        case SysCommand.Dormancy:
                            SysCommandManager.Dormancy();
                            break;

                        case SysCommand.VolumeDown:
                            SysCommandManager.VolumeDown();
                            break;

                        case SysCommand.VolumeUp:
                            SysCommandManager.VolumeUp();
                            break;

                        case SysCommand.VolumeMute:
                            SysCommandManager.VolumeMute();
                            break;

                        case SysCommand.CancelShutDown:
                            SysCommandManager.CancelShutDown();
                            break;

                        case SysCommand.Restart:
                            SysCommandManager.Restart();
                            break;
                        }
                        break;

                    case StreamType.CommandPPT:
                        PPTCommand        pptCommand = (PPTCommand)command;
                        PPTCommandManager manager    = PPTCommandManager.GetInstance();
                        switch (pptCommand)
                        {
                        case PPTCommand.Start:
                            manager.Start();
                            break;

                        case PPTCommand.Next:
                            manager.Next();
                            break;

                        case PPTCommand.Last:
                            manager.Last();
                            break;

                        case PPTCommand.Exit:
                            manager.Exit();
                            break;
                        }
                        break;

                    case StreamType.CommandAV:
                        AVCommand        avCommand        = (AVCommand)command;
                        AVCommandManager avCommandManager = AVCommandManager.GetInstance();
                        switch (avCommand)
                        {
                            /*
                             * case AVCommand.AVStart:
                             * if (FrmAV.GetInstance() == null)
                             * {
                             *  FrmAV.GetInstance(FrmAV.FormType.Callee).Show();
                             * }
                             * break;
                             * case AVCommand.AVAccept:
                             * if (FrmAV.GetInstance() != null)
                             * {
                             *  avCommandManager.BeginMonitorWebcam(FrmAV.GetInstance().avLocalhost);
                             * }
                             * break;
                             * case AVCommand.AVRefuse:
                             * if (FrmAV.GetInstance() != null)
                             * {
                             *  FrmAV.GetInstance().lbTips.Text = "对方拒绝了您的请求";
                             * }
                             * break;
                             * case AVCommand.AVSuspend:
                             * if (FrmAV.GetInstance() != null)
                             * {
                             *  FrmAV.GetInstance().lbTips.Text = "对方挂断了视频";
                             * }
                             * break;
                             */
                        }
                        break;

                    case StreamType.VideoStream:
                        /*
                         * byte[] bytes2 = new byte[buffertemp.Length - 8];
                         * Buffer.BlockCopy(buffertemp, 8, bytes2, 0, buffertemp.Length - 8);
                         * if (FrmAV.GetInstance() != null)
                         * {
                         *  MemoryStream stream = new MemoryStream(bytes2);
                         *
                         *  FrmAV.GetInstance().avPhone.Image = System.Drawing.Image.FromStream(stream);
                         * }
                         * else
                         * {
                         *  FrmAV.GetInstance(FrmAV.FormType.Callee).Show();
                         *  MemoryStream stream = new MemoryStream(bytes2);
                         *
                         *  FrmAV.GetInstance().avPhone.Image = System.Drawing.Image.FromStream(stream);
                         * }
                         */
                        break;
                    }
                }
            }
            byte[] buffertemp2 = new byte[BUFFERSIZE];
            //recSocket = tcpListener.EndAccept(ar);
            recSocket.BeginReceive(buffertemp2, 0, BUFFERSIZE, SocketFlags.None, new AsyncCallback(ReceiveHandle), buffertemp2);
        }