Very simple question. Why does the client that has just connected not receive any messages, but all other clients get the broadcast? What's the correct way of sending the client that connected a message?
protected override void OnConnected(HttpContextBase context, string clientId)
{
GameAction message = new GameAction();
message.text = "Player connected";
Connection.Broadcast(serializer.Serialize(message));
GameAction gamestate = new GameAction();
gamestate.text = "Some client specific info";
Send(clientId, serializer.Serialize(gamestate));
}
I think you should put a call back function in a connection.start() function in your javascript and resend your command. Separate type of broadcast message and echo message in JSON may help you detect status of connection after you join in... The bellows work for me..
.....
connection.start({ callback: function () {
var username = getCookie("username");
connection.send(window.JSON.stringify({ type: 0, value: username }));
}
});
......
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With