コード例 #1
0
        private void Start()
        {
            if (!_onScene)
            {
                DontDestroyOnLoad(gameObject);
                _onScene = true;
            }
            else
            {
                Destroy(gameObject);
            }
#if UNITY_EDITOR
            try
            {
#endif
            _webConnector = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <WebConnector>();
#if UNITY_EDITOR
        }
        catch (Exception)
        {
            // ignored
        }
#endif
            _homeMessageManager = GameObject.FindGameObjectWithTag("HomeManager").GetComponent <HomeMessageManager>();
        }
コード例 #2
0
ファイル: Web.cs プロジェクト: zkniebel/SharePoint-Connect
        public Web GetWeb([NotNull] string webName)
        {
            string webUrl    = StringUtil.EnsurePostfix('/', this.Context.Url) + StringUtil.RemovePrefix('/', webName);
            var    connector = new WebConnector(this.Context, new Uri(webUrl));

            return(new Web(connector.GetWeb(), this.Context));
        }
コード例 #3
0
        private void btnSendRequest_Click(object sender, System.EventArgs e)
        {
            int requestId = WebConnector.SendRequest(this.txtRequestContent.Text, requesterId, receiverId);

            if (requestId != 0)
            {
                MessageBox.Show("Your request was succesffully sent!", "Request sent", MessageBoxButtons.OK, MessageBoxIcon.Information);

                RequestInformation request = new RequestInformation();
                request.Id          = requestId;
                request.RequesterId = this.requesterId;
                request.Requester   = this.sender;
                request.UserId      = this.receiverId;
                request.State       = 1;
                request.RequestText = this.txtRequestContent.Text;

                string jsonRequest = JsonConvert.SerializeObject(request);

                socketHelper.SendMessage(this.username, jsonRequest, this.sender.Username, @"/request");

                // Ask parent to remove oneself from it's controls list
                this.Parent.Controls.Remove(this);
                this.Dispose();
            }
            else
            {
                MessageBox.Show("Whoops, there was an issue while sending your request. Please try again.", "Request sending failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #4
0
    private IEnumerator SaveSettingsCoroutine()
    {
        Game.Me.PanelLoading.SetActive(true);
        Game.Me.PanelLoading.GetComponent <PanelLoading>().TextTop = "Saving name...";

        WWW    www     = null;
        string newName = InputFieldTextName.GetComponent <InputField>().text;

        if (newName.Length == 0)
        {
            newName = "Empty";
        }
        if (newName.Length > 9)
        {
            newName = newName.Substring(0, 9);
        }
        newName = Regex.Replace(newName, "\\W", "");
        InputFieldTextName.GetComponent <InputField>().text = newName;
        if (newName != Game.Me.UserName)
        {
            www = WebConnector.ChangeName(newName);
            Game.Me.UserName = newName;
        }

        yield return(new WaitForSeconds(1f));

        yield return(www);

        Game.Me.PanelLoading.SetActive(false);
    }
コード例 #5
0
        private void StartCheckExecute(object obj)
        {
            _webConnectorContinuous = new WebConnector();

            string reservePage = _webConnectorTemporary.CallHtmlAPI(Configs.webAPI, Configs.uriGetReservePage(ScheduleID), CookieText);

            if (!ExtractInitData(reservePage))
            {
                Process.Start("chrome.exe", Configs.webAPI + Configs.uriGetReservePage(ScheduleID));
                return;
            }

            Blocks blocks = _webConnectorTemporary.CallAPI <Blocks>(Configs.webAPI, Configs.uriGetBlocks(ScheduleID), CookieText);

            if (blocks.data.Length > 0)
            {
                _webConnectorContinuous.CallAPIAsync <Blocks>(Configs.webAPI, Configs.uriGetBlocks(ScheduleID), ASYNC_API_CALL_INTERVAL, AddRemainSeatData, CookieText);
            }
            else
            {
                _webConnectorContinuous.CallAPIAsync <Grades>(Configs.webAPI, Configs.uriGetGrades(ScheduleID), ASYNC_API_CALL_INTERVAL, AddRemainSeatData, CookieText);
            }

            IsInProgress = true;
        }
コード例 #6
0
ファイル: Index.cshtml.cs プロジェクト: Regis-1/AspNet
        public void OnPost()
        {
            ViewData["confirmedCases"] = $"Po kliknięciu {country}";

            wc = new WebConnector("https://api.covid19api.com/");
            DateTime t1            = dateFrom;
            DateTime t2            = dateTo;
            string   manyDays      = "";
            string   countryOutput = country;

            countryOutput.ToLower();
            if (t1.Date == t2.Date)
            {
                wc.SetRecentTotalByCountry(countryOutput);
                CountryData cd2 = JsonParser.ExtractListData <CountryData>(wc.Connect())[0];
                ViewData["confirmedCases"] = "Potwierdzone przypadki: " + cd2.Confirmed.ToString();
            }
            else if (DateTime.Compare(t1, t2) < 0)
            {
                wc.SetPeriodTotalByCountry(country, t1, t2);
                List <CountryData> cdl = JsonParser.ExtractListData <CountryData>(wc.Connect());
                int      _c            = 0;
                DateTime tTemp         = t1;
                foreach (CountryData cd in cdl)
                {
                    manyDays += tTemp.AddDays(_c).ToShortDateString() + ": " + cd.Confirmed.ToString() + "\n";
                    _c++;
                }
                ViewData["confirmedCases"] = "Potwierdzone przypadki od " + t1.ToShortDateString() + " do " + t2.ToShortDateString() + " :\n" + manyDays;
            }
            else
            {
                ViewData["confirmedCases"] = $"Data 'Od' jest późniejsza od daty 'Do'!";
            }
        }
コード例 #7
0
    private void UpdateText(List <LevelScore> scores)
    {
        ImageYellowStraw.SetActive(true);
        TextLeaderboardNames.GetComponent <Text>().text  = "";
        TextLeaderboardScores.GetComponent <Text>().text = "";

        foreach (LevelScore tmp in scores)
        {
            if (tmp == null || tmp.DeviceId == null)
            {
                TextLeaderboardNames.GetComponent <Text>().text  += "---\n";
                TextLeaderboardScores.GetComponent <Text>().text += "---\n";
            }
            else
            {
                string name = tmp.Name;
                //in case we changed the name in settings and want this to apply without another useless server call
                if (tmp.DeviceId == WebConnector.GetDeviceId())
                {
                    name = Game.Me.UserName;
                }
                TextLeaderboardNames.GetComponent <Text>().text  += tmp.Place + ". " + name + "\n";
                TextLeaderboardScores.GetComponent <Text>().text += "" + tmp.Interventions + " INTERV, " + tmp.Time.ToString("##.##") + " s\n";
            }
        }

        string tmp2 = TextLeaderboardNames.GetComponent <Text>().text;

        TextLeaderboardNames.GetComponent <Text>().text = tmp2.Substring(0, tmp2.Length - 1);
        tmp2 = TextLeaderboardScores.GetComponent <Text>().text;
        TextLeaderboardScores.GetComponent <Text>().text = tmp2.Substring(0, tmp2.Length - 1);
    }
コード例 #8
0
ファイル: GlobalView.cshtml.cs プロジェクト: Regis-1/AspNet
        private void WebApi()
        {
            //Creating webconnector
            wc = new WebConnector("https://api.covid19api.com/");

            var globalDataSets = (from s in _context.GlobalDataBase select s).ToList <GlobalDataBase>();

            DateTime today     = DateTime.Today;
            bool     existance = false;

            if (_context.GlobalDataBase.Any(record => record.DateDataBase == today))
            {
                existance = true;
            }
            if (!existance)
            {
                wc.SetGlobalSummary();
                GlobalData gd1 = JsonParser.ExtractSingleData <GlobalData>(wc.Connect(), "Global");
                _context.GlobalDataBase.Add(new GlobalDataBase {
                    TotalConfirmed = gd1.TotalConfirmed, DateDataBase = today
                });
                _context.SaveChanges();
            }

            if (existance)
            {
                Console.WriteLine("Todays data already in the data base.");
            }
            else if (!existance)
            {
                Console.WriteLine("Todays data added.");
            }

            Console.WriteLine("\n***Global data checked!***\n");
        }
コード例 #9
0
        public Test1()
        {
            userName = ConfigurationSettings.AppSettings["defaultUser1"];// "DM241228";// "DM709822";
            password = ConfigurationSettings.AppSettings["passwordUser1"];
            domain   = ConfigurationSettings.AppSettings["domain"];

            webConnection = new WebConnector(domain, userName, password);
        }
コード例 #10
0
        private void ConnectWebAPIs()
        {
            _webConnector = new WebConnector();
            var marketTypes = _webConnector.CallAPI <MarketType>(Configs.webAPI, Configs.uriGetMarkets, "Downloading Coin Types...");

            CoinTypes = new ObservableCollection <string>(marketTypes.Where(x => x.market.Contains("KRW")).Select(x => x.coin_name));
            CoinTypes.Insert(0, "WON");
            SelectedCoin = CoinTypes[0];
        }
コード例 #11
0
    private IEnumerator RestartLevelsCoroutine()
    {
        GetComponent <ButtonsInCloud>().ClonedPanelButtons.SetActive(false);
        TextInfo.GetComponent <Text>().text = "Restarting levels...";
        yield return(new WaitForSeconds(1f));

        yield return(WebConnector.RestartLevels());

        StartCoroutine(LoadMissionCoroutine(MissionType.Specified, false));
    }
コード例 #12
0
    public WWW SaveGame(Dictionary <ScoreType, Result> actualResults)
    {
        int   intervetions = (int)actualResults[ScoreType.Interventions].Value;
        float time         = actualResults[ScoreType.Time].Value;
        bool  isRecord     = intervetions < YourBest.Interventions || (intervetions == YourBest.Interventions && time < YourBest.Time);
        bool  getScores    = isRecord;
        WWW   www          = WebConnector.SendMissionAccomplished(_MissionType, _Name, _Round, GetStatus(actualResults), actualResults, getScores);

        return(www);
    }
コード例 #13
0
        public MainWindowViewModel()
        {
            StartCheckButton       = new CommandBase(StartCheckExecute, StartCheckCanExecute);
            StopButton             = new CommandBase(StopExecute);
            ClearButton            = new CommandBase(ClearExecute);
            ProductRoundList       = new ObservableCollection <ProductRound>();
            CurrentRemainSeats     = new ObservableCollection <RemainSeatData>();
            GradeList              = new ObservableCollection <Grade>();
            BlockList              = new ObservableCollection <Meta.Draw.BlockInfo>();
            RemainSeats            = new ObservableCollection <RemainSeatData>();
            _webConnectorTemporary = new WebConnector();

            Messenger.Instance.Register <string>(this, (s) => { StatusText = s; }, Context.PROGRESS_DESC);
        }
コード例 #14
0
        public void GetCurrentUnitPrice()
        {
            if (_webConnector != null)
            {
                return;
            }

            _webConnector = AssetName != "WON" ? new WebConnector() : null;
            _webConnector?.CallAPIAsync <Ticker>(
                Configs.webAPI,
                Configs.UriGetTickerOf("KRW-" + AssetName),
                500,
                (t) => { CurrentUnitPrice = t.First().trade_price; });
        }
コード例 #15
0
        private void removeFromContactsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UserInfoContainer activeContainer = GetActiveUserContainer();

            if (activeContainer != null)
            {
                int userId = activeContainer.UserId;

                // Add connector line
                WebConnector.RemoveContact(userId.ToString(), this.accountInfo.Id.ToString());

                this.RespositionContacts(activeContainer);
                this.pnlContactsContainer.Controls.Remove(activeContainer);
            }
        }
コード例 #16
0
ファイル: Endpoint.cs プロジェクト: JamPaul97/PokemonSaves
 public Contest.Bases.Effect this[uint index]
 {
     get
     {
         if (Cacher.HasEntry(URL.Replace("/", ""), -1))
         {
             return(Newtonsoft.Json.JsonConvert.DeserializeObject <Contest.Bases.Effect>(System.IO.File.ReadAllText(Cacher.Read(URL.Replace("/", ""), -1))));
         }
         else
         {
             var obj = JsonConvert.DeserializeObject <Contest.Bases.Effect>(WebConnector.Request(SingleURL(index)));
             Cacher.Cache(URL.Replace("/", ""), (int)index, obj);
             return(obj);
         }
     }
 }
コード例 #17
0
ファイル: Endpoint.cs プロジェクト: JamPaul97/PokemonSaves
 public Pokemon.Bases.Nature this[uint index]
 {
     get
     {
         if (Cacher.HasEntry(URL.Replace("/", ""), (int)index))
         {
             return(JsonConvert.DeserializeObject <Pokemon.Bases.Nature>(System.IO.File.ReadAllText(Cacher.Read(URL.Replace("/", ""), (int)index))));
         }
         else
         {
             var obj = JsonConvert.DeserializeObject <Pokemon.Bases.Nature>(WebConnector.Request(SingleURL(index)));
             Cacher.Cache(URL.Replace("/", ""), (int)index, obj);
             return(obj);
         }
     }
 }
コード例 #18
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            if (!ValidateTextboxes())
            {
                return;
            }

            if (WebConnector.Register(this.txtUsername.Text, this.txtPassword.Text, this.txtEmail.Text, CreateBase64Image(pboxAvatarContainer.Image)))
            {
                MessageBox.Show("You have been successfully registered!", "Registration successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("An error occurred while trying to register your account. Please try again.", "Registration error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #19
0
        private void UserInfoContainer_RequestRejected(object sender)
        {
            int requestId = 0;
            UserInfoContainer requestContainer  = sender as UserInfoContainer;
            Point             containerLocation = requestContainer.Location;

            this.pnlAvailableRequests.Controls.Remove(requestContainer);
            this.pnlAvailableRequests.Invalidate();

            foreach (Control control in this.pnlAvailableRequests.Controls)
            {
                if (control is UserInfoContainer)
                {
                    if (control.Location.Y > containerLocation.Y)
                    {
                        control.Location = new Point(control.Location.X, (control.Location.Y - control.Height));
                    }
                }
            }

            // Get the ID of the request itself
            foreach (RequestInformation request in this.requests)
            {
                if (request.Requester.Id == requestContainer.UserId)
                {
                    requestId = request.Id;
                    break;
                }
            }

            // Delete request from the database
            WebConnector.DeleteRequest(requestId);

            // Remove the current request both from the panel and the list containing the requests
            this.requests.RemoveAll(request => request.Requester.Id == requestContainer.UserId);

            // If there's no requests - no need to keep the header up anymore.
            if (requests.Count == 0)
            {
                this.pnlContactsContainer.Controls.Remove(this.pnlAvailableRequests);
            }
        }
コード例 #20
0
        /// <summary>
        /// 上传到SME
        /// </summary>
        /// <param name="data_path"></param>
        /// <returns></returns>
        public async Task <string> UploadToSME(string data_path)
        {
            using (StreamReader reader = new StreamReader(data_path))
            {
                try
                {
                    string xmlStr = await reader.ReadToEndAsync();

                    WebConnector  webconnector = new WebConnector();
                    StringBuilder sb           = new StringBuilder();
                    string        session_id   = webconnector.GetSessionId();
                    webconnector.SendXml(session_id, xmlStr, sb);
                    return(sb.ToString());
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }
        }
コード例 #21
0
    private IEnumerator LoadMissionCoroutine(MissionType mt, bool toRepeat)
    {
        WWW www = WebConnector.LoadMission(mt, toRepeat);

        yield return(www);

        if (www.error != null)
        {
            Debug.Log("Some errors occured: " + www.error);
            TextInfo.GetComponent <Text>().text = "Internet connection required: " + www.error;
            GetComponent <ButtonsInCloud>().ClonedPanelButtons.SetActive(true);
            GetComponent <ButtonsInCloud>().ClonedPanelButtons.GetComponent <PanelButtons>().ButtonTop.SetActive(false);
        }
        else
        {
            try {
                JSONNode n       = JSONNode.Parse(www.text);
                string   name    = n["missionName"];
                int      round   = n["round"].AsInt;
                string   jsonMap = WWW.UnEscapeURL(n["map"]);

                Game.Me.UserName = WWW.UnEscapeURL(n["name"]);

                List <LevelScore> scores = ParseScores(n["results"]);

                if (jsonMap == null || jsonMap == "" || jsonMap == "null")
                {
                    TextInfo.GetComponent <Text>().text = "There are no more missions. \n\nVisit fb page for updates.";
                    GetComponent <ButtonsInCloud>().ClonedPanelButtons.SetActive(true);
                }
                else
                {
                    PanelBeforeMission.SetActive(true);
                    PanelBeforeMission.GetComponent <PanelBeforeMission>().MissionBriefing(new Mission(jsonMap, mt, name, round, scores[3], scores));
                    gameObject.SetActive(false);
                }
            } catch (System.Exception e) {
                Debug.Log("Exception: " + e);
            }
        }
    }
コード例 #22
0
        private void AddRequestToContacts(UserInfoContainer container)
        {
            int contactListBottom = GetContactsListLength();
            int requestId         = 0;

            // Get the ID of the request itself
            foreach (RequestInformation request in this.requests)
            {
                if (request.Requester.Id == container.UserId)
                {
                    requestId = request.Id;
                    break;
                }
            }

            RepositionRemainingRequests(container);

            container.Location = new Point(0, contactListBottom);
            contactListBottom += container.Height;

            container.Parent = this.pnlContactsContainer;
            this.pnlContactsContainer.Controls.Add(container);
            this.listContactContainer.Add(container);

            int offset = GetContactsListLength();

            this.pnlAvailableRequests.Location = new Point(this.pnlAvailableRequests.Location.X, offset);

            // Send query to the API so that we actually add the user to the database
            WebConnector.AddContact(this.accountInfo.Id, container.UserId);
            // Remove the request
            WebConnector.DeleteRequest(requestId);

            // Tell server to propagate the request to the accepted client if he's currently available
            string jsonClientInfo = JsonConvert.SerializeObject(this.accountInfo);

            // Send as message
            socketHelper.SendMessage(container.Username, jsonClientInfo, this.accountInfo.Username, @"/accept");
        }
コード例 #23
0
        private void txtSearch_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter && this.txtSearch.Text != string.Empty)
            {
                if (!this.socketHelper.IsAuthorized)
                {
                    return;
                }

                if (this.pnlAvailableUsers == null)
                {
                    this.pnlAvailableUsers = new Panel();

                    this.CreateGroupHeader("AVAILABLE USERS", this.pnlAvailableUsers, lblContactsList.Location, lblSeparator.Location);

                    this.pnlAvailableUsers.Name     = "pnlAvailableUsers";
                    this.pnlAvailableUsers.Location = pnlContactsContainer.Location;
                    this.pnlAvailableUsers.Size     = new Size(pnlContactsContainer.Size.Width, pnlContactsContainer.Size.Height - txtSearch.Height);
                }
                else
                {
                    this.ClearAvailableUsersList();
                }

                List <AccountInformation> users = WebConnector.GetAvailableUsers(this.txtSearch.Text, this.accountInfo.Id);

                foreach (AccountInformation contact in this.contacts.ContactsList)
                {
                    users.RemoveAll(user => user.Id == contact.Id);
                }

                this.pnlDashboard.Controls.Add(pnlAvailableUsers);
                this.pnlContactsContainer.Hide();

                // Add user controls to the available users container
                this.ListAvailableUsers(users);
                this.isSearchViewLoaded = true;
            }
        }
コード例 #24
0
        public SysTrayApp()
        {
            // Setup tray icon
            _ni         = new NotifyIcon();
            _ni.Icon    = Resources.iconfinder_audio_console_44847;
            _ni.Text    = "Arduino Volume Service";
            _ni.Visible = true;

            // Logger to reccord info/debug stuff
            _logger = new Logger(100);

            // Setup tray icon to have a menu
            _contextMenus                  = new ContextMenus();
            _contextMenus.ExitClicked     += _contextMenus_ExitClicked;
            _contextMenus.ShowLogsClicked += _contextMenus_ShowLogsClicked;
            _ni.ContextMenuStrip           = _contextMenus.Create();

            // Device control connects to windows OS
            _deviceController = new DeviceController();
            _deviceController.DeviceVolChangedEvent   += _deviceController_DeviceVolChangedEvent;
            _deviceController.DeviceListResponseEvent += _deviceController_DeviceListChangedEvent;

            // Setup serial connector
            _serialCon = new SerialConnector();
            _serialCon.StateChangeEvent     += _serialCon_StateChangeEvent;
            _serialCon.CommandReceivedEvent += _serialCon_CommandReceivedEvent;

            _connKeepAliveThread = new Thread(KeepConnAlive);

            _webAccessHost = new WebConnector(_webHostUrl);
            _webAccessHost.WebStateChangeEvent += _webAccessHost_WebStateChangeEvent;
            _webAccessHost.WebCommandEvent     += _webAccessHost_WebCommandEvent;
            _webAccessHost.WebRequestBoundDevicesChangeEvent += _webAccessHost_WebRequestBoundDevicesChangeEvent;

            _webAccessHost.StartWeb();
            _serialCon.Connect();
            _connKeepAliveThread.Start();
        }
コード例 #25
0
    private IEnumerator LoadDataCoroutine()
    {
        WWW www = null;

        try {
            www = WebConnector.GetInitialData();
        } catch (Exception e) {
            Debug.Log("exception: " + e);
        }
        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.Log("www error: " + www.error);

            PanelLoading.GetComponent <PanelLoading>().JustDo  = () => { PrepareLoading(); };
            PanelLoading.GetComponent <PanelLoading>().TextTop = "Internet connection required. (" + www.error + ")";
            PanelLoading.GetComponent <PanelLoading>().TextTap = "Tap to retry";
        }
        else
        {
            JSONNode n = JSONNode.Parse(www.text);

            if (HasGoodVersion(n))
            {
                ParseInitialData(n);
            }
            else
            {
                PanelLoading.GetComponent <PanelLoading>().JustDo = () => { Application.OpenURL("https://play.google.com/store/apps/details?id=com.kprojekt.fingerofgod"); };
                string headlines = n["thisVersionHeadlines"].Value;
                PanelLoading.GetComponent <PanelLoading>().TextTop = "There is new version with: " + headlines;
                PanelLoading.GetComponent <PanelLoading>().TextTap = "Tap to update";
            }
        }
    }
コード例 #26
0
ファイル: Services.cs プロジェクト: RENSting/Source
 public WebApiConnector(IOptionsSnapshot <WebConnectorSettings> options)
 {
     _connector = new WebConnector(
         options.Value.Applications.First(app => app.Name == WebConnector.DEFAULT).BaseUrl);
 }
コード例 #27
0
        private void socketHelper_SocketDataReceived(string data)
        {
            if (socketHelper.IsHandshake)
            {
                BaseResponse <AccountInformation> response = JsonConvert.DeserializeObject <BaseResponse <AccountInformation> >(data);

                if (response != null && response.Status == 200)
                {
                    this.accountInfo = response.Data;

                    this.contacts = WebConnector.GetContactsData(accountInfo.Id);
                    this.requests = WebConnector.GetAvailableRequests(accountInfo.Id);

                    this.DisplayContactsAndRequests();

                    this.socketHelper.IsHandshake  = false;
                    this.socketHelper.IsAuthorized = true;

                    this.UpdateClientMenu(true);
                }
                else
                {
                    MessageBox.Show("An error occurred: " + response.ErrorMessage, "Error logging in", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    this.socketHelper.CloseConnection();
                    this.UpdateClientMenu(false);
                }

                return;
            }

            Message message       = Message.CreateMessageObject(data);
            bool    isCallContent = false;

            if (message == null || (message.Command.Equals("/disconnect") && message.Content.Equals("OK")))
            {
                socketHelper.CloseConnection();

                UpdateClientOnDisconnect();
                return;
            }
            else if (message.Command.Equals(@"/online"))
            {
                string username = message.Content;
                ChangeOnlineStatus(username);

                return;
            }
            else if (message.Command.Equals(@"/request"))
            {
                RequestInformation request = null;

                try
                {
                    //Console.WriteLine(message.Content);
                    request = JsonConvert.DeserializeObject <RequestInformation>(message.Content);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("An error occurred while parsing request command: " + ex.Message);
                }

                if (request != null)
                {
                    this.requests.Add(request);
                    this.FillRequestsList();
                }

                return;
            }
            else if (message.Command.Equals(@"/accept"))
            {
                AccountInformation contact = null;

                try
                {
                    contact = JsonConvert.DeserializeObject <AccountInformation>(message.Content);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("An error occurred while parsing accept command: " + ex.Message);
                }

                if (contact != null)
                {
                    this.contacts.ContactsList.Add(contact);
                    this.AppendContact(contact);

                    this.ChangeOnlineStatus(contact.Username);

                    socketHelper.SendMessage(contact.Username, this.accountInfo.Username, this.accountInfo.Username, @"/online");
                }

                return;
            }
            else if (message.Command.Equals(@"/offline"))
            {
                string username = message.Content;
                ChangeOnlineStatus(username);

                return;
            }
            else if (message.Command.Contains("call"))
            {
                isCallContent = true; // We set it to true to avoid dumping call ID's into the message box

                if (message.Command.Equals("/call"))
                {
                    this.callSoundPlayer.PlayLooping();

                    MessengerContainer msgWindow = GetActiveMessengerContainer(message.Sender);
                    if (msgWindow != null)
                    {
                        msgWindow.CreateCallDialog(message.Sender);
                        msgWindow.callDialog.CallStateChanged += callDialog_CallStateChanged;
                    }
                }
                else if (message.Command.Contains("/accept"))
                {
                    MessengerContainer msgWindow = GetActiveMessengerContainer(message.Sender);

                    if (msgWindow != null)
                    {
                        msgWindow.InitiatingCall = false;
                    }

                    this.socketHelper.EstablishCall(this.accountInfo.Username);
                }
                else if (message.Command.Contains("/close"))
                {
                    if (this.socketHelper.CallHelper != null)
                    {
                        this.socketHelper.CloseCall();
                    }

                    MessengerContainer msgWindow = GetActiveMessengerContainer(message.Sender);
                    if (msgWindow != null)
                    {
                        msgWindow.InitiatingCall = false;

                        msgWindow.UpdateCallState();
                        msgWindow.callDialog.CallStateChanged -= callDialog_CallStateChanged;
                    }
                }
            }

            if (message.Content != string.Empty && !isCallContent)
            {
                if (message.Sender == this.accountInfo.Username)
                {
                    this.DumpMessage(message, true);
                }
                else
                {
                    this.DumpMessage(message);

                    this.notificationSoundPlayer.Play();
                    SetContainerNotification(message.Sender);
                }
            }
        }
コード例 #28
0
ファイル: TestUserController.cs プロジェクト: RENSting/Source
 public TestUserController()
 {
     _connector = new WebConnector("https://localhost:5001");
 }
コード例 #29
0
 public Finder()
 {
     Connector = new WebConnector();
 }
コード例 #30
0
 public BaseClass()
 {
     Connector = new WebConnector();
 }