Files
sbox-public/engine/Sandbox.Engine/Game/PartyRoom/PartyRoom.Message.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

47 lines
915 B
C#

namespace Sandbox;
partial class PartyRoom
{
const int ProtocolIdentity = 5084;
enum MessageIdentity : long
{
ChatMessage = 1001,
VoiceMessage = 1002,
}
public void SendChatMessage( string text )
{
var bs = ByteStream.Create( 128 );
bs.Write( ProtocolIdentity );
bs.Write( MessageIdentity.ChatMessage );
bs.Write( text );
steamLobby.SendChatData( bs.ToArray() );
}
void ILobby.OnMemberMessage( Friend friend, ByteStream stream )
{
var protocol = stream.Read<int>();
if ( protocol != ProtocolIdentity )
{
Log.Warning( $"Unknown Protocol from {friend}" );
return;
}
var ident = stream.Read<MessageIdentity>();
if ( ident == MessageIdentity.ChatMessage )
{
var contents = stream.Read<string>();
Log.Info( $"[Party] {friend}: {contents}" );
OnChatMessage?.Invoke( friend, contents );
return;
}
Log.Warning( $"Unhandled message from {friend}" );
}
}