Send request function

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Baiumka
Posts: 9
Joined: 04 Dec 2018, 09:57

Send request function

Postby Baiumka » 24 Jan 2019, 20:14

Hello, i wrote i function for a comfy sending request.

Code: Select all

Client.SendRequest("CheckLogin","Login|Baium","Pass|123");

public static void SendRequest(string Command, params string[] arg)
    {
        SFSObject obj = new SFSObject();
        foreach (string a in arg)
        {
            string key = a.Split('|')[0];
            string value = a.Split('|')[1];
            try { int val = Convert.ToInt32(value); obj.PutInt(key, val); } catch { }
            try { bool val = Convert.ToBoolean(value); obj.PutBool(key, val); } catch { }
            try { obj.PutUtfString(key, value); } catch { }
        }
        Client.connect_link.Send(new ExtensionRequest(Command, obj, Client.connect_link.LastJoinedRoom));
    }


Rate it pls, and tell me if you know esialy or better decision.
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Send request function

Postby Lapo » 25 Jan 2019, 08:46

Hi,
I am not sure what to say :)
If this is useful for your use case go ahead and use it :) I don't see any particular problem with it.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 28 guests