SLikeNet
0.1.3
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
RelayPlugin.h
Go to the documentation of this file.
1
/*
2
* Original work: Copyright (c) 2014, Oculus VR, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
7
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
8
*
9
*
10
* Modified work: Copyright (c) 2016-2017, SLikeSoft UG (haftungsbeschränkt)
11
*
12
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13
* license found in the license.txt file in the root directory of this source tree.
14
*/
15
19
20
21
#include "
NativeFeatureIncludes.h
"
22
#if _RAKNET_SUPPORT_RelayPlugin==1
23
24
#ifndef __RELAY_PLUGIN_H
25
#define __RELAY_PLUGIN_H
26
27
#include "
PluginInterface2.h
"
28
#include "
string.h
"
29
#include "
DS_Hash.h
"
30
34
35
namespace
SLNet
36
{
37
39
class
RakPeerInterface;
40
41
enum
RelayPluginEnums
42
{
43
// Server handled messages
44
RPE_MESSAGE_TO_SERVER_FROM_CLIENT
,
45
RPE_ADD_CLIENT_REQUEST_FROM_CLIENT
,
46
RPE_REMOVE_CLIENT_REQUEST_FROM_CLIENT
,
47
RPE_GROUP_MESSAGE_FROM_CLIENT
,
48
RPE_JOIN_GROUP_REQUEST_FROM_CLIENT
,
49
RPE_LEAVE_GROUP_REQUEST_FROM_CLIENT
,
50
RPE_GET_GROUP_LIST_REQUEST_FROM_CLIENT
,
51
// Client handled messages
52
RPE_MESSAGE_TO_CLIENT_FROM_SERVER
,
53
RPE_ADD_CLIENT_NOT_ALLOWED
,
54
RPE_ADD_CLIENT_TARGET_NOT_CONNECTED
,
55
RPE_ADD_CLIENT_NAME_ALREADY_IN_USE
,
56
RPE_ADD_CLIENT_SUCCESS
,
57
RPE_USER_ENTERED_ROOM
,
58
RPE_USER_LEFT_ROOM
,
59
RPE_GROUP_MSG_FROM_SERVER
,
60
RPE_GET_GROUP_LIST_REPLY_FROM_SERVER
,
61
RPE_JOIN_GROUP_SUCCESS
,
62
RPE_JOIN_GROUP_FAILURE
,
63
};
64
67
class
RAK_DLL_EXPORT
RelayPlugin
:
public
PluginInterface2
68
{
69
public
:
70
// GetInstance() and DestroyInstance(instance*)
71
STATIC_FACTORY_DECLARATIONS
(
RelayPlugin
)
72
73
74
RelayPlugin
();
75
77
virtual
~
RelayPlugin
();
78
83
RelayPluginEnums
AddParticipantOnServer(
const
RakString
&key,
const
RakNetGUID
&guid);
84
86
void
RemoveParticipantOnServer(
const
RakNetGUID
&guid);
87
91
void
SetAcceptAddParticipantRequests(
bool
accept);
92
97
void
AddParticipantRequestFromClient(
const
RakString
&key,
const
RakNetGUID
&relayPluginServerGuid);
98
100
void
RemoveParticipantRequestFromClient(
const
RakNetGUID
&relayPluginServerGuid);
101
109
void
SendToParticipant(
const
RakNetGUID
&relayPluginServerGuid,
const
RakString
&destinationGuid,
BitStream
*bitStream,
PacketPriority
priority,
PacketReliability
reliability,
char
orderingChannel);
110
111
void
SendGroupMessage(
const
RakNetGUID
&relayPluginServerGuid,
BitStream
*bitStream,
PacketPriority
priority,
PacketReliability
reliability,
char
orderingChannel);
112
void
JoinGroupRequest(
const
RakNetGUID
&relayPluginServerGuid,
RakString
groupName);
113
void
LeaveGroup(
const
RakNetGUID
&relayPluginServerGuid);
114
void
GetGroupList(
const
RakNetGUID
&relayPluginServerGuid);
115
117
virtual
PluginReceiveResult
OnReceive(
Packet
*packet);
119
virtual
void
OnClosedConnection(
const
SystemAddress
&systemAddress,
RakNetGUID
rakNetGUID,
PI2_LostConnectionReason
lostConnectionReason );
120
121
struct
StrAndGuidAndRoom
122
{
123
RakString
str
;
124
RakNetGUID
guid
;
125
RakString
currentRoom
;
126
};
127
128
struct
StrAndGuid
129
{
130
RakString
str
;
131
RakNetGUID
guid
;
132
};
133
134
struct
RP_Group
135
{
136
RakString
roomName
;
137
DataStructures::List<StrAndGuid>
usersInRoom
;
138
};
139
140
protected
:
141
142
RelayPlugin::RP_Group
* JoinGroup(
RakNetGUID
userGuid,
RakString
roomName);
143
RelayPlugin::RP_Group
* JoinGroup(
RP_Group
* room,
StrAndGuidAndRoom
**strAndGuidSender);
144
void
LeaveGroup(
StrAndGuidAndRoom
**strAndGuidSender);
145
void
NotifyUsersInRoom(
RP_Group
*room,
int
msg,
const
RakString
& message);
146
void
SendMessageToRoom(
StrAndGuidAndRoom
**strAndGuidSender,
BitStream
* message);
147
void
SendChatRoomsList(
RakNetGUID
target);
148
void
OnGroupMessageFromClient(
Packet
*packet);
149
void
OnJoinGroupRequestFromClient(
Packet
*packet);
150
void
OnLeaveGroupRequestFromClient(
Packet
*packet);
151
152
DataStructures::Hash<RakString, StrAndGuidAndRoom*, 8096, SLNet::RakString::ToInteger>
strToGuidHash
;
153
DataStructures::Hash<RakNetGUID, StrAndGuidAndRoom*, 8096, SLNet::RakNetGUID::ToUint32>
guidToStrHash
;
154
DataStructures::List<RP_Group*>
chatRooms
;
155
bool
acceptAddParticipantRequests
;
156
157
};
158
159
}
// End namespace
160
161
#endif
162
163
#endif // _RAKNET_SUPPORT_*
Source
include
slikenet
RelayPlugin.h
Generated on Wed Aug 14 2019 22:09:46 for SLikeNet by
1.8.2