private void OnGetMatch(GetMatchResult result)
    {
        //storing the players IDs on the PlayersIDSaver two join them
        string p1 = result.Members[0].Attributes.DataObject.ToString();
        string p2 = result.Members[1].Attributes.DataObject.ToString();

        Debug.Log("..." + p1);
        Debug.Log("..." + p2);
        string p1ID = "";
        string p2ID = "";

        //reading the id of the two players
        for (int i = 7; i < p1.Length - 2; i++)
        {
            p1ID += p1[i];
        }
        for (int i = 7; i < p2.Length - 2; i++)
        {
            p2ID += p2[i];
        }
        Debug.Log(p1ID);
        Debug.Log(p2ID);
        idSaver.ManageIDs(p1ID, p2ID);
        //sending my selected level data to the other player
        EftClient.Send(Application.persistentDataPath + "/Multiplayer Levels/" + PlayerPrefs.GetString("selectedLevelName") + ".level",
                       ID_Generator.ID_to_IP(PlayerPrefs.GetString("otherPlayerID")), 9999);
        matchmakingObjects.SetActive(false);
        gameplayObjects.SetActive(true);
    }
Example #2
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            string fn = (string)e.Argument;

            EasyFileTransfer.Model.Response rsp = EftClient.Send(fn, textBox2.Text, Convert.ToInt32(textBox1.Text));
            timer1.Stop();
            progressBar1.BeginInvoke((MethodInvoker)(() => progressBar1.Value = 100));
            MessageBox.Show(rsp.description, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            progressBar1.BeginInvoke((MethodInvoker)(() => progressBar1.Value = 0));
        }
Example #3
0
 public static void RemoveClient(EftClient client)
 {
     for (int i = 0; i < Clients.Count; i++)
     {
         if (Clients[i].UniqueSession == client.UniqueSession)
         {
             Clients.RemoveAt(i);
             i--;
         }
     }
 }
Example #4
0
 private void SnedButton_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         EasyFileTransfer.Model.Response rsp = EftClient.Send(openFileDialog1.FileName, textBox2.Text, Convert.ToInt32(textBox1.Text));
         if (rsp.status == 1)
         {
             MessageBox.Show("send successfully.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
Example #5
0
 public static void AddClient(EftClient client)
 {
     if (client == null)
     {
         return;
     }
     if (GetClient(client.UniqueSession) != null)
     {
         RemoveClient(client);
     }
     Clients.Add(client);
 }
Example #6
0
        public void Handle(RequestData data)
        {
            HttpListenerResponse serverResponse = data.Context.Response;

            Log.Info($"Authentication requested from client at {data.Context.Request.RemoteEndPoint}");
            serverResponse.StatusCode  = (int)HttpStatusCode.OK;
            serverResponse.ContentType = "text/plain";
            serverResponse.AddHeader("Content-Encoding", "deflate");
            EftClient client = data.Client;

            byte[] messageBytes = ZlibStream.CompressString(AuthenticationService.Authenticate(ref client, data.Body));
            serverResponse.OutputStream.Write(messageBytes, 0, messageBytes.Length);
            serverResponse.SetCookie(new Cookie("PHPSESSID", client.UniqueSession));;
            serverResponse.Close();
        }
        public static string Authenticate(ref EftClient client, string data)
        {
            string result = string.Empty;
            var    login  = Serializer.Deserialize <LoginRequest>(data);
            var    sid    = StringUtil.GenerateRandomString(16, true);

            if (client == null)
            {
                client = new EftClient(sid, login.DeviceId);
            }
            else
            {
                client.UniqueIdentifier = login.DeviceId;
                client.UniqueSession    = sid;
            }
            client.Authenticated = true;
            client.Email         = login.Email;
            client.Password      = login.Pass;
            Server.AddClient(client);
            return(Serializer.Read("./Templates/Account.json"));
        }