mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-12-02 22:18:09 +01:00
* First time ever messing with sockets, but i think it should be good ? * Note: I put the definition alongside Windows64 but it may be more suited under a Linux.cmake file... No reason for the Windows64 group to be in Common though
91 lines
2.6 KiB
C++
91 lines
2.6 KiB
C++
#pragma once
|
|
|
|
#if defined(__linux__)
|
|
|
|
#include <atomic>
|
|
#include <deque>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "..\..\Common\Network\NetworkPlayerInterface.h"
|
|
|
|
class Socket;
|
|
|
|
class NetworkPlayerLinux : public INetworkPlayer {
|
|
public:
|
|
NetworkPlayerLinux(int userIndex, unsigned char smallId, bool isLocal, bool isHost, const std::wstring& name);
|
|
virtual ~NetworkPlayerLinux();
|
|
|
|
virtual unsigned char GetSmallId();
|
|
virtual void SendData(INetworkPlayer* player, const void* pvData, int dataSize, bool lowPriority, bool ack);
|
|
virtual bool IsSameSystem(INetworkPlayer* player);
|
|
virtual int GetOutstandingAckCount();
|
|
virtual int GetSendQueueSizeBytes(INetworkPlayer* player, bool lowPriority);
|
|
virtual int GetSendQueueSizeMessages(INetworkPlayer* player, bool lowPriority);
|
|
virtual int GetCurrentRtt();
|
|
virtual bool IsHost();
|
|
virtual bool IsFakeHost();
|
|
virtual bool IsGuest();
|
|
virtual bool IsLocal();
|
|
virtual int GetSessionIndex();
|
|
virtual bool IsTalking();
|
|
virtual bool IsMutedByLocalUser(int userIndex);
|
|
virtual bool HasVoice();
|
|
virtual bool HasCamera();
|
|
virtual int GetUserIndex();
|
|
virtual void SetSocket(Socket* pSocket);
|
|
virtual Socket* GetSocket();
|
|
virtual const wchar_t* GetOnlineName();
|
|
virtual std::wstring GetDisplayName();
|
|
virtual PlayerUID GetUID();
|
|
virtual void SentChunkPacket();
|
|
virtual int GetTimeSinceLastChunkPacket_ms();
|
|
|
|
void SetHost(bool isHost);
|
|
void SetHostTransport(bool isServer);
|
|
void SetFakeHost(bool isFakeHost);
|
|
void SetSmallId(unsigned char smallId);
|
|
void SetUID(PlayerUID uid);
|
|
void SetDisplayName(const std::wstring& name);
|
|
void SetSessionIndex(int index);
|
|
void ResetForSession(bool isHost, unsigned char smallId);
|
|
void SetTransportSocket(int socket, unsigned long remoteAddress);
|
|
int GetTransportSocket() const;
|
|
bool IsConnected() const;
|
|
bool ReceivePendingData(bool hostIsServer);
|
|
bool FlushSendQueue();
|
|
void CloseTransport(bool isServerConnection);
|
|
|
|
std::vector<unsigned char> m_systemFlags;
|
|
|
|
private:
|
|
void RefreshUID();
|
|
NetworkPlayerLinux* GetTransportPlayer(INetworkPlayer* player);
|
|
int GetQueueSizeBytes();
|
|
int GetQueueSizeMessages();
|
|
|
|
int m_userIndex;
|
|
unsigned char m_smallId;
|
|
bool m_isLocal;
|
|
bool m_isHost;
|
|
bool m_isHostTransport;
|
|
bool m_isFakeHost;
|
|
int m_sessionIndex;
|
|
std::wstring m_name;
|
|
PlayerUID m_uid;
|
|
bool m_hasResolvedUID;
|
|
ULONGLONG m_lastChunkPacketTick;
|
|
Socket* m_gameSocket;
|
|
std::atomic<int> m_transportSocket;
|
|
std::atomic<bool> m_connected;
|
|
unsigned long m_remoteAddress;
|
|
mutable std::mutex m_transportMutex;
|
|
mutable std::mutex m_sendQueueMutex;
|
|
std::deque<std::vector<char>> m_sendQueue;
|
|
size_t m_sendQueueOffset;
|
|
size_t m_sendQueueBytes;
|
|
};
|
|
|
|
#endif
|