Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTMP Get other player id #1453

Closed
ugurrdemirel opened this issue Oct 20, 2016 · 13 comments
Closed

RTMP Get other player id #1453

ugurrdemirel opened this issue Oct 20, 2016 · 13 comments

Comments

@ugurrdemirel
Copy link

ugurrdemirel commented Oct 20, 2016

Hi. I have own username, score etc. system. I want get other player's id (not participantid, Social.localuser.id) for authenticate user from my web server. Everythink has been normal so far. I'm sending id in bytes but other player can't acces correct id. For example if my id is : 12345678, other player is getting 000012. How can I fix that ? Sorry for my bad english :)

This is ID sending part of script

public void SendID(string id)
    {
        DataList.Clear ();
        DataList.Add ((byte)'I');
        string temp;
        temp= id.Substring(1, 19); // I used substring because player id like "g1234", this method converting id for "1234" 
        float number;
        number= float.Parse (temp);
        DataList.AddRange (System.BitConverter.GetBytes (number));
        byte[] messageToSend= DataList.ToArray ();
        PlayGamesPlatform.Instance.RealTime.SendMessageToAll (false, messageToSend);
    }
public void OnRealTimeMessageReceived (bool isReliable, string senderId, byte[] data)
{
    char messageType= (char)data [0];
    if (messageType== 'I') {
        if (senderId != PlayGamesPlatform.Instance.RealTime.GetSelf ().ParticipantId) {
            float idFloat = System.BitConverter.ToSingle(data,1);
            OtherPlayerID.SendMessage("Check" , idFloat); //send id for other script 
        }
    }
}

Other Script

function Check (PlayerID : float) 
{
    var IdInt: int = Mathf.RoundToInt(PlayerID); // I'm using this convertion because PlayerID is incoming from float type, this is causing "123.00" so  I'm converting float to int "123"
    var CheckAccount: WWW = new WWW("myserver.com/CheckUsers.php?id=g" +WWW.EscapeURL(IdInt.ToString("D")));
    yield CheckAccount;
}
@SamihElsakhawi
Copy link

any news about that?

I'm looking for the participant id.

@ugurrdemirel
Copy link
Author

ugurrdemirel commented Jul 15, 2017 via email

@SamihElsakhawi
Copy link

Do you know how could i get the opponent user name?

@ugurrdemirel
Copy link
Author

ugurrdemirel commented Jul 15, 2017 via email

@SamihElsakhawi
Copy link

Is it the only way? a simpler solution must exist.

Because when i receive an invitation from another player, i create a pop up notification in game that shows the opponent Username with this:

string opponentUserName = mIncomingInvitation.Inviter.DisplayName;

@ugurrdemirel
Copy link
Author

ugurrdemirel commented Jul 16, 2017 via email

@SamihElsakhawi
Copy link

SamihElsakhawi commented Jul 16, 2017

Okay, thanks!

So i came to this for sending the user name to the other player:

PlayerUserName = PlayGamesPlatform.Instance.RealTime.GetSelf().DisplayName;

var PlayerUserNameBytes = System.Text.Encoding.UTF8.GetBytes(PlayerUserName); bool reliable = true; PlayGamesPlatform.Instance.RealTime.SendMessageToAll(reliable, PlayerUserNameBytes);

But after how could i receive the other opponent message?

@ugurrdemirel
Copy link
Author

ugurrdemirel commented Jul 16, 2017 via email

@SamihElsakhawi
Copy link

Do you have a sample of code to achieve that? because i'm trying but nothing worked. :/

Thanks a lot!

@ugurrdemirel
Copy link
Author

ugurrdemirel commented Jul 17, 2017 via email

@SamihElsakhawi
Copy link

Thank you for sharing your code!

But i've got an error at this line:

usernameBytes.AddRange(Encoding.GetEncoding ("UTF-8").GetBytes (characters));

Errors are :

  • error CS0103: The name `Encoding' does not exist in the current context

  • error CS1502: The best overloaded method match for `System.Collections.Generic.List.AddRange(System.Collections.Generic.IEnumerable)' has some invalid arguments

  • error CS1503: Argument #1' cannot convert object' expression to type `System.Collections.Generic.IEnumerable'

How could i fix that?

@ugurrdemirel
Copy link
Author

ugurrdemirel commented Jul 19, 2017 via email

@SamihElsakhawi
Copy link

Thank you! i miss the using System.Text; assembly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants