示例#1
0
    public void CmdEnter(string exp, string message)
    {
        string responseJSONS = CallServer.Sim(exp, MultiplayerTableCreator.variableJSON);

        responseJSONS = CallServer.ToSimplify(responseJSONS);
        string responseJSON = CallServer.CallServerOnTautology(responseJSONS, MultiplayerTableCreator.variableJSON);

        int    before       = responseJSON.IndexOf("\"result\": ") + "result\": ".Length + 1;
        int    after        = responseJSON.IndexOf("\n}");
        string sampleString = responseJSON.Substring(before, after - before);

        if (sampleString == "true")
        {
            Debug.Log("Tautology, not accepted");
            RpcupdateFeedBack("Tautology not accepted. Try again!", false);
            return;
        }
        if (MultiplayerEnter.acceptedInv.Count > 0)
        {
            if (CallServer.Implied(responseJSONS, MultiplayerEnter.acceptedInv, MultiplayerTableCreator.variableJSON) == true)
            {
                Debug.Log("Implied statement, not accepted");
                RpcupdateFeedBack("Implied statement not accepted. Try again!", false);
                return;
            }
        }
        Json = responseJSONS;
        RpcupdateFeedBack("Invariant accepted. Nice work!", true);
        temp = exp;
        //tableCreatorInstance.counter++;

        //text = panel.transform.Find("Text (1)").gameObject;
        //text.GetComponent<Text>().text += GetInputExpression.exp + '\n';
        RpcupdateScore();
    }
示例#2
0
 // Use this for initialization
 void Start()
 {
     currentJson = CallServer.ExecuteServerCall();
     json        = new JSONParser(currentJson);
     startTime   = Time.time;
     LoadTable(json);
 }
示例#3
0
 public void ChangeMultiLevel()
 {
     TableCreator.currentJson = CallServer.ExecuteServerCall();
     TableCreator.counter     = 0;
     TableCreator.score       = 0;
     SceneManager.LoadScene("Multiplayer");
 }
        public static void RemoveServerDoServerDir(string urlServerDir, string url)
        {
            var call = new CallServer(urlServerDir);

            call.Action(Actions.Offline)
            .Params(new Tuple <string, string>("url", url))
            .ExecuteGet();
        }
        public static void RegistraNoServerDir(string urlServerDir, string urlCalculadoraServer, string operacoes)
        {
            var call = new CallServer(urlServerDir);

            call.Action(Actions.Online)
            .Params(new Tuple <string, string>("url", urlCalculadoraServer),
                    new Tuple <string, string>("actions", operacoes))
            .ExecuteGet();
        }
示例#6
0
        public void SendToServer()
        {
            if (tcpcontentfield.Text != "")
            {
                multiversprotocol.mp.tcpSend(Encoding.Unicode.GetBytes(tcpcontentfield.Text));

                CallServer.SetTitle("Send", UIControlState.Normal);
                tcpcontentfield.Text = null;
            }
        }
示例#7
0
    //Chun's tester



    public void Enter()
    {
        var tableCreatorInstance = tableCreator.GetComponent <TableCreator>();

        Debug.Log("Entered");
        for (int i = 0; i < tableCreatorInstance.rows; i++)
        {
            if (tableCreatorInstance.textArray[i, tableCreatorInstance.cols - 1].GetComponent <Text>().text != "True")
            {
                Debug.Log("returning");
                return;
            }
        }

        /*
         * looks like this:
         *   "{\n  \"id\": 1, \n  \"jsonrpc\": \"2.0\", \n  \"result\": true\n}\n"
         */
        // new code to call server whenever an invariant is entered
        //string responseJSON = CallServer.ExpToJS(GetInputExpression.exp);
        string responseJSONS = CallServer.Sim(GetInputExpression.exp, tableCreatorInstance.variableJSON);

        responseJSONS = CallServer.ToSimplify(responseJSONS);
        string responseJSON = CallServer.CallServerOnTautology(responseJSONS, tableCreatorInstance.variableJSON);

        int    before       = responseJSON.IndexOf("\"result\": ") + "result\": ".Length + 1;
        int    after        = responseJSON.IndexOf("\n}");
        string sampleString = responseJSON.Substring(before, after - before);

        if (sampleString == "true")
        {
            Debug.Log("Tautology, not accepted");
            feedbackBox.GetComponent <Text>().text = "Tautology not accepted. Try again!";
            return;
        }
        if (tableCreatorInstance.acceptedInv.Count > 0)
        {
            if (CallServer.Implied(responseJSONS, tableCreatorInstance.acceptedInv, tableCreatorInstance.variableJSON) == true)
            {
                Debug.Log("Implied statement, not accepted");
                feedbackBox.GetComponent <Text>().text = "Implied statement not accepted. Try again!";
                return;
            }
        }
        tableCreatorInstance.acceptedInv.AddLast(responseJSONS);

        feedbackBox.GetComponent <Text>().text = "Invariant accepted. Nice work!";
        TableCreator.counter++;
        TableCreator.score++;
        TableCreator.startTime = Time.time;
        text = panel.transform.Find("Text (1)").gameObject;
        text.GetComponent <Text>().text += GetInputExpression.exp + '\n';
        Debug.Log(TableCreator.counter);
    }
示例#8
0
        public void TestServer()
        {
            multiversprotocol.tcpsocket.srvIP   = "YOUR_ASR_IP";
            multiversprotocol.tcpsocket.srvPort = 100;
            multiversprotocol.mp.tcpSend(Encoding.Unicode.GetBytes("asrphone_byte_test"));

            CallServer.SetTitle("Send", UIControlState.Normal);
            tcpcontentfield.Hidden = false;
            connected            = true;
            getidbutton.Hidden   = false;
            getserverinfo.Hidden = false;
            internbutton.Hidden  = false;
        }
        public double Divisao(long x, long y)
        {
            var urlOper = GetServer("Divisao");

            ValidaUrl(urlOper);
            var callCalc = new CallServer(urlOper);
            var result   = callCalc.Action(Actions.Divisao)
                           .Params(new Tuple <string, string>("x", x.ToString()),
                                   new Tuple <string, string>("y", y.ToString()))
                           .ExecuteGet();

            return(GetResult(result));
        }
        void ReleaseDesignerOutlets()
        {
            if (asrphonelabel != null)
            {
                asrphonelabel.Dispose();
                asrphonelabel = null;
            }

            if (CallServer != null)
            {
                CallServer.Dispose();
                CallServer = null;
            }

            if (getidbutton != null)
            {
                getidbutton.Dispose();
                getidbutton = null;
            }

            if (getserverinfo != null)
            {
                getserverinfo.Dispose();
                getserverinfo = null;
            }

            if (infocontent != null)
            {
                infocontent.Dispose();
                infocontent = null;
            }

            if (ipBox != null)
            {
                ipBox.Dispose();
                ipBox = null;
            }

            if (logField != null)
            {
                logField.Dispose();
                logField = null;
            }

            if (tcpcontentfield != null)
            {
                tcpcontentfield.Dispose();
                tcpcontentfield = null;
            }
        }
 // Use this for initialization
 void Start()
 {
     feedbackBox = GameObject.Find("Feedback Box");
     canvas.AddComponent <RectTransform>();
     canvas.AddComponent <Canvas>();
     canvas.AddComponent <CanvasScaler>();
     canvas.AddComponent <GraphicRaycaster>();
     currentJson = CallServer.ExecuteServerCall();
     LogMessage += "Current Json: " + currentJson + "\n";
     json        = new JSONParser(currentJson);
     LogMessage += "MTC line 55\n";
     startTime   = Time.time;
     LoadTable(json);
 }
 public void Execute()
 {
     if (string.IsNullOrEmpty(SessionIdentity.Token))
     {
         InstallNewService();
     }
     else
     {
         var resutl = CallServer.POSTJson(websiteLink + "/Api/DynamicMicros/KeepAlive", SessionIdentity.Token);
         if (resutl.Replace("\\", "").Replace("\"", "") != "Ok")
         {
             MDService.UI.Program.serviceTask.Restart();
         }
     }
 }
示例#13
0
 //public static int level = 1;
 public void ChangeSingleLevel()
 {
     //if (level == 1)
     //{
     //  level = 2;
     TableCreator.currentJson = CallServer.ExecuteServerCall();     //"{ \"id\":2, \"jsonrpc\":\"2.0\", \"result\":{ \"LevelNumber\":5,\"data\":[[[1,7,0],[2,7,1],[3,7,3],[4,7,6],[5,7,10],[6,7,15],[7,7,21]],[],[]],\"goal\":\"verify\",\"hint\":null,\"id\":\"s-gauss_sum_true-unreach-call-auto\",\"lvlSet\":\"fb\",\"startingInvs\":[],\"typeEnv\":{\"i\":\"int\",\"n\":\"int\",\"sum\":\"int\"},\"variables\":[\"i\",\"n\",\"sum\"]}}";
     //}
     //else if (level == 2)
     //{
     //  level = 1;
     //TableCreator.currentJson = CallServer.ExecuteServerCall();//"{\"id\":68,\"jsonrpc\":\"2.0\",\"result\":{\"LevelNumber\":6,\"ShowQuestionaire\":true,\"data\":[[[1,0,7,0],[2,1,7,1],[3,2,7,3],[4,3,7,6],[5,4,7,10],[6,5,7,15],[7,6,7,21]],[],[]],\"goal\":\"verify\",\"hint\":null,\"id\":\"m - sorin03 - auto\",\"lvlSet\":\"fb\",\"startingInvs\":[],\"typeEnv\":{\"i\":\"int\",\"j\":\"int\",\"n\":\"int\",\"s\":\"int\"},\"variables\":[\"i\",\"j\",\"n\",\"s\"]}}";
     //}
     TableCreator.counter = 0;
     TableCreator.score   = 0;
     SceneManager.LoadScene("SinglePlayer");
 }
示例#14
0
        /// <summary>
        /// 默认构造函数
        /// </summary>
        public MainForm()
        {
            InitializeComponent();
            //绑定顶层关闭程序事件处理
            CommonEvent.CloseProgramEvent += CommonEvent_CloseProgramEvent;
            //实现阴影立体效果
            FormShadow.SetShadow(this);

            this.TopMost            = true;//设置为顶级窗口
            this.BottomPanel.Paint += BottomPanel_Paint;
            //设置右下角图标
            this.BottomRightIcon.Icon    = GrayIcon;
            this.BottomRightIcon.Click  += BottomRightIcon_Click;
            this.BottomRightIcon.Visible = true;

            //连接远程通信服务器
            if (!CallServer.InitCallServer())
            {
                System.Environment.Exit(1);
            }

            //初始化聊天界面
            this.chatForm         = new ChatForm();
            this.chatForm.Visible = false;
            chatForm.FormClosed  += ChatForm_FormClosed;
            //绑定双击打开聊天记录事件
            this.DownForm.RequestChat += DownForm_RequestChat;

            //实例化闹钟,用来显示消息
            ShowNewsTimer          = new System.Windows.Forms.Timer();
            ShowNewsTimer.Interval = 500;
            ShowNewsTimer.Enabled  = false;

            //实例化登录界面
            signInForm = new SignIn();
            signInForm.Show();
            signInForm.ShowInTaskbar = false;
            //显示托盘图标,放在这里,通过默认图标为不显示,防止图标重复出现
            this.BottomRightIcon.Visible = true;

            //绑定相关事件
            ConnectEvent();
            //初始化登录界面
            signInForm.init();
        }
示例#15
0
        /// <summary>
        /// 登录事件
        /// </summary>
        /// <param name="o"></param>
        private void SignInForm_FinishSignIn(object o, string account)
        {
            //初始界面为消息界面
            this.DownForm.MessageGroupBox.PerformClick();
            //初始化主界面
            this.UpForm.EmailLabel.Text = account;
            UserInformation.Account     = account;

            //初始化昵称???云请求
            FunctionWords functionWordsForUserName = this.SendNewsAndReceiveAnswer(FunctionKind.SeekForUserName, account, "", null);

            if (functionWordsForUserName != null && functionWordsForUserName.stringList.Count > 0)
            {
                this.UpForm.UserNameLabel.Text = functionWordsForUserName.stringList[0];
                UserInformation.UserName       = functionWordsForUserName.stringList[0];
            }

            //初始化图像???云请求
            FunctionWords functionWordsForImage = this.SendNewsAndReceiveAnswer(FunctionKind.SeekForImage, account, "", null);

            if (functionWordsForImage != null && functionWordsForImage.bitmapList.Count > 0)
            {
                this.UpForm.UserImagePictureBox.BackgroundImage = functionWordsForImage.bitmapList[0];
                UserInformation.Image = functionWordsForImage.bitmapList[0];
            }

            //初始化主窗体
            init();

            CommonEvent.AddNewFriendEvent           += CommonEvent_AddNewFriendEvent;
            CommonEvent.AddNewGroupEvent            += CommonEvent_AddNewGroupEvent;
            CommonEvent.AddNewMessageEvent          += CommonEvent_AddNewMessageEvent;
            CommonEvent.OnlineChangeEvent           += CommonEvent_OnlineChangeEvent;
            CommonEvent.AnswerApplyToAddFriendEvent += CommonEvent_AnswerApplyToAddFriendEvent;
            CommonEvent.AnswerApplyToAddGroupEvent  += CommonEvent_AnswerApplyToAddGroupEvent;

            //向服务器声明自己
            CallServer.AddSendNews(MessageProtocol.GetStartBytes(FunctionKind.DeclareConnect), MessageBirdCommon.UserInformation.Account.ToTxtBytes(), MessageProtocol.GetEndBytes());

            //模拟好友/群聊消息接收
            RunVirtualMessage();
        }
示例#16
0
        /// <summary>
        /// 执行注册操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RunButton_Click(object sender, EventArgs e)
        {
            //初步判断邮箱符合规则
            if (!this.EmailAccount.Text.Contains("@"))
            {
                MessageBox.Show("请输入合法的邮箱", "账户不符合规则");
                return;
            }

            //确认昵称符合规则
            if (this.NameTextBox.Text == "" || this.NameTextBox.Text.Contains(" ") || this.NameTextBox.Text.Contains("|") || this.NameTextBox.Text.Contains(@"\"))
            {
                MessageBox.Show(@"昵称不能为空,且不能含有空格、|、\", "信息不符合规则");
                return;
            }

            //确认密码符合规则
            if (this.Password1.Text != this.Password2.Text)
            {
                MessageBox.Show("您两次输入的密码不一致,请重试", "密码不符合规则");
                return;
            }

            if (!File.Exists(ImagePathTextBox.Text) || (!ImagePathTextBox.Text.EndsWith(".jpg") && !ImagePathTextBox.Text.EndsWith(".png")))
            {
                MessageBox.Show("请选择可用的图像,建议为正方形", "图像不符合规则");
                return;
            }
            //确认验证码
            if (this.ConfigString == "" || this.ConfigString != this.ConfigTextBox.Text)
            {
                MessageBox.Show("验证码错误,请重新填写验证码", "系统消息");
                return;
            }
            //与服务器通信,修改参数
            //账户:EmailAccount.Text
            //昵称:NameTextBox.Text
            //密码:Password1.Text
            CallServer.AddSendNews(MessageProtocol.GetStartBytes(FunctionKind.RequestToRegeditAccount), EmailAccount.Text.ToTxtBytes(), NameTextBox.Text.ToTxtBytes(), Password1.Text.ToTxtBytes(), MessageProtocol.GetEndBytes());
            MessageBox.Show("修改成功", "系统消息");
        }
示例#17
0
    // Use this for initialization
    void Start()
    {
        string stringtest = "1 == 1";

        CallServer.ExpToJS(stringtest);
    }
示例#18
0
        /// <summary>
        /// 发送请求
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void sendbutton_Click(object sender, EventArgs e)
        {
            if (this.sendbutton.Text == "发送请求")
            {
                switch (currentFunction)
                {
                case FunctionChoice.AddFriend:
                    if (!this.accountTextbox.Text.EndsWith(".com") || this.accountTextbox.Text == "")
                    {
                        MessageBox.Show("请输入正确的好友邮箱");
                        return;
                    }

                    //云验证账户,并请求昵称???
                    FunctionWords functionWordsForFriendUserName = this.SendNewsAndReceiveAnswer(FunctionKind.SeekForUserName, this.accountTextbox.Text, "", null);
                    if (functionWordsForFriendUserName != null && functionWordsForFriendUserName.stringList.Count > 0)
                    {
                        this.userNameTextBox.Text = functionWordsForFriendUserName.stringList[0];
                        this.showBusyLabel.Text   = "已返回昵称,请确认";
                        break;
                    }
                    this.showBusyLabel.Text = "账户不存在";
                    return;

                case FunctionChoice.AddToGroup:
                    if (this.accountTextbox.Text.EndsWith(".com") || this.accountTextbox.Text == "")
                    {
                        MessageBox.Show("请输入正确的群号");
                        return;
                    }

                    //云验证账户,并请求昵称???
                    FunctionWords functionWordsForGroupUserName = this.SendNewsAndReceiveAnswer(FunctionKind.SeekForUserName, this.accountTextbox.Text, "", null);
                    if (functionWordsForGroupUserName != null && functionWordsForGroupUserName.stringList.Count > 0)
                    {
                        this.userNameTextBox.Text = functionWordsForGroupUserName.stringList[0];
                        this.showBusyLabel.Text   = "已返回昵称,请确认";
                        break;
                    }
                    this.showBusyLabel.Text = "账户不存在";
                    return;

                case FunctionChoice.CreateGroup:
                    if (this.userNameTextBox.Text == "")
                    {
                        MessageBox.Show("请输入正确的昵称");
                        return;
                    }

                    //云请求群号,返回群号???
                    FunctionWords functionWordsForCreateGroup = this.SendNewsAndReceiveAnswer(FunctionKind.SeekForNewGroupAccount, "", "", null);
                    if (functionWordsForCreateGroup != null && functionWordsForCreateGroup.stringList.Count > 0)
                    {
                        this.accountTextbox.Text = functionWordsForCreateGroup.stringList[0];
                        this.showBusyLabel.Text  = "已返回群号,请确认";
                        break;
                    }
                    this.showBusyLabel.Text = "服务器异常,请稍后重试";
                    return;

                default:
                    return;
                }
                this.sendbutton.Text = "确认";
            }
            else if (this.sendbutton.Text == "确认")
            {
                if (this.userNameTextBox.Text == "" || this.accountTextbox.Text == "")
                {
                    MessageBox.Show("错误: 似乎存在信息不完整,请重试");
                    this.sendbutton.Text = "发送请求";
                    return;
                }

                switch (currentFunction)
                {
                case FunctionChoice.AddFriend:
                    //发送请求???
                    CallServer.AddSendNews(MessageProtocol.GetStartBytes(FunctionKind.ApplyToAddFriend), MessageBirdCommon.UserInformation.Account.ToTxtBytes(), MessageBirdCommon.UserInformation.UserName.ToTxtBytes(), this.accountTextbox.Text.ToTxtBytes(), MessageProtocol.GetEndBytes());
                    break;

                case FunctionChoice.AddToGroup:
                    //发送请求???
                    CallServer.AddSendNews(MessageProtocol.GetStartBytes(FunctionKind.ApplyToAddGroup), MessageBirdCommon.UserInformation.Account.ToTxtBytes(), MessageBirdCommon.UserInformation.UserName.ToTxtBytes(), this.accountTextbox.Text.ToTxtBytes(), MessageProtocol.GetEndBytes());
                    break;

                case FunctionChoice.CreateGroup:
                    //发送请求???
                    MessageBox.Show("请选择小于30KB的png图片");
                    OpenFileDialog fileDialog = new OpenFileDialog();
                    DialogResult   result     = fileDialog.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        FileInfo fileInfo = new FileInfo(fileDialog.FileName);
                        double   length   = Convert.ToDouble(fileInfo.Length);
                        if (!fileInfo.FullName.ToLower().EndsWith(".png") || (fileInfo.Length > 31457280))
                        {
                            MessageBox.Show("目前仅支持小于30KB的png图像");
                            return;
                        }
                        Bitmap image = new Bitmap(Image.FromFile(fileDialog.FileName));
                        CallServer.AddSendNews(MessageProtocol.GetStartBytes(FunctionKind.RequestToRegeditGroup), MessageBirdCommon.UserInformation.Account.ToTxtBytes(), MessageBirdCommon.UserInformation.UserName.ToTxtBytes(), this.accountTextbox.Text.ToTxtBytes(), image.ToImageBytes(), MessageProtocol.GetEndBytes());
                    }
                    else
                    {
                        return;
                    }
                    break;

                default:
                    return;
                }
                MessageBox.Show("申请信息已发出");
                this.sendbutton.Text = "发送请求";
            }
        }
 protected CalculadoraClienteBase(string urlServer)
 {
     this.urlServer  = urlServer;
     this.CallServer = new CallServer(urlServer);
 }
    // Update is called once per frame
    void Update()
    {
        //Debug.Log("Counter from Table: " +counter);
        //SinglePlayer case

        /*if (SceneManager.Equals(SceneManager.GetActiveScene(), "SinglePlayer"))
         * {
         *  if (counter == 3)
         *  {
         *      displaySingleScore();
         *  }
         * }
         * else
         * {
         *  if (Time.time - startTime > 15)
         *  {
         *      displayMultiScore();
         *  }
         * }*/

        if (Time.time - startTime > timeLimit && SpaghettiGameManager.counter > 0)
        {
            if (Time.time - startTime > (timeLimit + 10))
            {
                canvas.SetActive(true);
                MultiplayerEnter.acceptedInv.Clear();
                scoreCanvas.SetActive(false);
                ClearTable();
                GameObject.Destroy(panel);
                SpaghettiGameManager.counter = 0;
                startTime     = Time.time;
                UpdateInv.Inv = "Invariants\n";
                currentJson   = CallServer.ExecuteServerCall();
                json          = new JSONParser(currentJson);
                LoadTable(json);
            }
            else
            {
                feedbackBox.GetComponent <Text>().text = "";
                canvas.SetActive(false);
                scoreCanvas.SetActive(true);
                Text scoreText = scoreDisplay.GetComponent <Text>();
                scoreText.text = "Your score: " + score + "\nYour Opponent: " + opponent;
            }
        }

        for (int i = 0; i < rows; i++)
        {
            var engine = new Engine();

            for (int k = 0; k < cols - 1; k++)

            {
                engine.SetValue(variables[k], data[0][i][k]);
            }
            try
            {
                if (GetInputExpression.exp.Length == 0)
                {
                    textArray[i, cols - 1].GetComponent <Text>().text = "";
                    //numbers.Clear();
                }
                else
                {
                    //Debug.Log(GetInputExpression.exp);
                    engine.Execute(GetInputExpression.exp);
                    //Debug.Log(engine.GetCompletionValue().ToObject());
                    textArray[i, cols - 1].GetComponent <Text>().text = (engine.GetCompletionValue().ToObject()).ToString();
                    float test = 0;
                    if (float.TryParse(textArray[i, cols - 1].GetComponent <Text>().text, out test))
                    {
                        textArray[i, cols - 1].GetComponent <Text>().text = test.ToString("G4");
                    }
                }
            }
            catch (Exception err)
            {
                //  Debug.Log(err.Message);
            }
        }
    }