-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSocketManager.h
More file actions
98 lines (78 loc) · 2.67 KB
/
Copy pathSocketManager.h
File metadata and controls
98 lines (78 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include <ThirdParty\Steamworks\Steamv147\sdk\public\steam\isteamnetworkingsockets.h>
#include <ThirdParty\Steamworks\Steamv147\sdk\public\steam\steamnetworkingtypes.h>
#include <ThirdParty\Steamworks\Steamv147\sdk\public\steam\steam_api.h>
#include "SocketManager.generated.h"
struct SMessage {
const char* Type;
// const void* Data;
};
struct Buffer
{
uint8_t* data; // pointer to buffer data
int size; // size of buffer data (bytes)
int index; // index of next byte to be read/written
int flag;
};
UCLASS()
class BONENSOUL_API ASocketManager : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ASocketManager();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
CSteamID LobbyRoom;
CSteamID Player1;
CSteamID OtherPlayer;
CSteamID Player2;
int Sock;
uint16_t MyPCounter;
ISteamNetworkingSockets* pInterface;
ISteamNetworkingUtils* NetUtils;
HSteamListenSocket ListenSocket;
HSteamNetConnection Connection;
TSharedPtr<class SMenuWidget> MenuWidget;
class IOnlineSubsystem* SubSystem;
class FOnlineSubsystemSteam* SubSystemsteam;
int g_nVirtualPortLocal; // Used when listening, and when connecting
int g_nVirtualPortRemote; // Only used when connecting
bool IsLan;
bool IsListening;
const char* penis;
// SteamNetworkingMessage_t* pMessages;
//SteamNetworkingMessage_t* const* pMessages2;
void ProcessPacket(SteamNetworkingMessage_t* _pMessage);
STEAM_CALLBACK(ASocketManager, OnSteamNetConnectionStatusChanged, SteamNetConnectionStatusChangedCallback_t);
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
bool InitializeConection();
bool TestInitializeConection(int baboon);
bool InitializeSockets(bool _IsLan);
bool SendMessage(Buffer _Buffer);
void SetRoomPlayers(CSteamID LobbyRoom);
void Disconnect();
void ShutdownSockets();
void Broadcast();
//read and write
bool WriteInteger(Buffer& buffer, uint32_t value);
//void WriteShort(Buffer& buffer, uint16_t value);
bool WriteChar(Buffer& buffer, uint8_t value);
bool WriteFloat(Buffer& buffer, float value);
bool WriteShort(Buffer& buffer, uint16_t value);
uint32_t ReadInteger(Buffer& buffer);
float ReadFloat(Buffer& buffer);
uint16_t ReadShort(Buffer& buffer);
uint8_t ReadByte(Buffer& buffer);
class UBoneNSoulGameInstance* GameInstance;
class ABoneNSoulGameSession* GameSession;
};
struct PacketStart {
char c;
};