28 lines
823 B
C#
28 lines
823 B
C#
|
using System.Net.WebSockets;
|
||
|
using Tiger.Communication.Messages.Interfaces;
|
||
|
using Tiger.Communication.Messages.Types;
|
||
|
using Tiger.Game.Habbos;
|
||
|
|
||
|
namespace Tiger.Networking.Game.Sessions;
|
||
|
|
||
|
public class GameSession
|
||
|
{
|
||
|
public WebSocket WebSocket { get; }
|
||
|
public string SessionId { get; }
|
||
|
public Habbo? Habbo { get; set; }
|
||
|
|
||
|
public GameSession(WebSocket webSocket, string sessionId)
|
||
|
{
|
||
|
WebSocket = webSocket;
|
||
|
SessionId = sessionId;
|
||
|
}
|
||
|
|
||
|
public async Task SendComposerAsync(IMessageComposer composer)
|
||
|
{
|
||
|
var message = new ServerMessage((short)composer.Header);
|
||
|
composer.Compose(message);
|
||
|
var bytes = message.ToArray();
|
||
|
await WebSocket.SendAsync(new ArraySegment<byte>(bytes), WebSocketMessageType.Binary, true,
|
||
|
CancellationToken.None);
|
||
|
}
|
||
|
}
|