mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-25 14:49:28 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
47 lines
915 B
C#
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}" );
|
|
|
|
}
|
|
}
|