public bool Run(NetworkStream stream, string input) { var proto = new LobbyTeam { Team = Convert.ToInt32(input) }; stream.Write(proto.ProtobufTypeAsBytes, 0, 2); ProtoBuf.Serializer.SerializeWithLengthPrefix(stream, proto, ProtoBuf.PrefixStyle.Fixed32); return(true); }
private bool HandleTeam(LobbyTeam command, Client client) { var teamToJoin = Team.From(command.Team); if (IsTeamFull(client, teamToJoin)) { return(false); } client.Info.Team = teamToJoin; Lobby.Broadcast("Player " + client.Info.Name + " joined team " + teamToJoin.Name + ".", false, client); return(true); }
protected virtual void OnPlayerTeamChanged(LobbyMember member, LobbyTeam newTeam) { var packet = new StringPairPacket() { A = member.Username, B = newTeam.Name }; // Broadcast the change var msg = MessageHelper.Create((short)OpCodes.LobbyMemberChangedTeam, packet.ToBytes()); Broadcast(msg); }
public bool Run(NetworkStream stream, string input) { var args = Regex.Split(input, @"\s+"); if (args.Length < 2 || args[1].Length <= 0) { return(false); } var proto = new LobbyTeam((int)Team.From(args[1].ToLower()).Index); stream.Write(proto.ProtobufTypeAsBytes, 0, 2); ProtoBuf.Serializer.SerializeWithLengthPrefix(stream, proto, ProtoBuf.PrefixStyle.Fixed32); return(true); }