Hi Rich,
It's super easy. Just assign the JSON string with your username/password to MetaJson. You can use whatever JSON library you like - Json.NET, DataContractJsonSerializer, etc. We provide a "Json" class that wraps the DataContractJsonSerializer, so if you go that route, here's how you would do it.
[DataContract]
class Credentials
{
[DataMember]
public string Username { get; set; }
[DataMember]
public string Password { get; set; }
}
Client
client.Connect(new ConnectArgs
{
MetaJson = Json.Serialize(new Credentials
{
Username = "...",
Password = "..."
});
});
Server
[WebSyncEvent(EventType.BeforeConnect)]
public static void Authenticate(object sender, WebSyncEventArgs e)
{
var credentials = Json.Deserialize<Credentials>(e.MetaJson);
if (!Authenticate(credentials))
{
e.Cancel("Authentication failed.");
}
}