void Test_P2P() { SteamP2P.SetOnP2PSessionRequest(OnP2PSessionRequest); SteamP2P.SetOnP2PSessionConnectFail(OnP2PSessionConnectFail); while (true) { //Networking.SendString(new SteamPlayer(SteamCore.PlayerId()), "Hello"); Networking.SendString(new SteamPlayer(76561198060676433), "Hello to 76561198060676433"); Networking.SendString(new SteamPlayer(76561198201081585), "Hello to 76561198201081585"); var bytes = File.ReadAllBytes("Content/Maps/Beset.m3n"); var s = new MessageGameState(0, bytes).MakeFullMessage().ToString(); s = s.Substring(0, 100); Networking.SendString(new SteamPlayer(76561198060676433), s); while (SteamP2P.MessageAvailable()) { var msg = Networking.ReceiveString(); Console.WriteLine("got message! {0}", msg); } } }
public static Message Parse(string s) { var Type = Pop <MessageType>(ref s); var message = new Message(Type); switch (message.Type) { case MessageType.PlayerAction: message.Inner = MessagePlayerAction.Parse(s); break; case MessageType.PlayerActionAck: message.Inner = MessagePlayerActionAck.Parse(s); break; case MessageType.Bookend: message.Inner = MessageBookend.Parse(s); break; case MessageType.GameState: message.Inner = MessageGameState.Parse(s); break; case MessageType.StartingStep: message.Inner = MessageStartingStep.Parse(s); break; case MessageType.Hash: message.Inner = MessageHash.Parse(s); break; case MessageType.StringHash: message.Inner = MessageStringHash.Parse(s); break; } return(message); }