mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-15 15:53:55 +00:00
1. Fixed crash that occured in metadata
2. Added support for server.connections
This commit is contained in:
@@ -70,12 +70,12 @@ typedef struct ILibAsyncServerSocketModule
|
||||
#endif
|
||||
#endif
|
||||
}ILibAsyncServerSocketModule;
|
||||
struct ILibAsyncServerSocket_Data
|
||||
typedef struct ILibAsyncServerSocket_Data
|
||||
{
|
||||
struct ILibAsyncServerSocketModule *module;
|
||||
ILibAsyncServerSocket_BufferReAllocated Callback;
|
||||
void *user;
|
||||
};
|
||||
}ILibAsyncServerSocket_Data;
|
||||
|
||||
const int ILibMemory_ASYNCSERVERSOCKET_CONTAINERSIZE = (const int)sizeof(ILibAsyncServerSocketModule);
|
||||
|
||||
@@ -750,6 +750,27 @@ void ILibAsyncServerSocket_GetLocal(ILibAsyncServerSocket_ServerModule ServerSoc
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t ILibAsyncServerSocket_GetConnections(ILibAsyncServerSocket_ServerModule server, ILibAsyncServerSocket_ConnectionToken *connections, size_t connectionsSize)
|
||||
{
|
||||
ILibAsyncServerSocketModule *mod = (ILibAsyncServerSocketModule*)server;
|
||||
if (connections == NULL || connectionsSize < mod->MaxConnection) { return((size_t)mod->MaxConnection); }
|
||||
int i;
|
||||
size_t x = 0;
|
||||
for (i = 0; i < mod->MaxConnection; ++i)
|
||||
{
|
||||
if (ILibAsyncSocket_IsConnected(mod->AsyncSockets[i]))
|
||||
{
|
||||
ILibAsyncServerSocket_Data *data = (ILibAsyncServerSocket_Data*)ILibAsyncSocket_GetUser(mod->AsyncSockets[i]);
|
||||
connections[x++] = mod->AsyncSockets[i];
|
||||
}
|
||||
}
|
||||
return(x);
|
||||
}
|
||||
void *ILibAsyncServerSocket_GetUser(ILibAsyncServerSocket_ConnectionToken *token)
|
||||
{
|
||||
return(((ILibAsyncServerSocket_Data*)ILibAsyncSocket_GetUser(token))->user);
|
||||
}
|
||||
/*! \fn ILibAsyncServerSocket_GetPortNumber(ILibAsyncServerSocket_ServerModule ServerSocketModule)
|
||||
\brief Returns the port number the server is bound to
|
||||
\param ServerSocketModule The ILibAsyncServer to query
|
||||
|
||||
@@ -117,6 +117,10 @@ ILibAsyncServerSocket_ServerModule ILibCreateAsyncServerSocketModuleWithMemory(v
|
||||
ILibAsyncServerSocket_ServerModule ILibCreateAsyncServerSocketModuleWithMemoryExMOD(void *Chain, int MaxConnections, int initialBufferSize, struct sockaddr* local, ILibAsyncServerSocket_OnConnect OnConnect, ILibAsyncServerSocket_OnDisconnect OnDisconnect, ILibAsyncServerSocket_OnReceive OnReceive, ILibAsyncServerSocket_OnInterrupt OnInterrupt, ILibAsyncServerSocket_OnSendOK OnSendOK, int mod, int ServerUserMappedMemorySize, int SessionUserMappedMemorySize);
|
||||
#define ILibCreateAsyncServerSocketModuleWithMemoryEx(Chain, MaxConnections, initialBufferSize, local, OnConnect, OnDisconnect, OnReceive, OnInterrupt, OnSendOK, ServerUserMappedMemorySize, SessionUserMappedMemorySize) ILibCreateAsyncServerSocketModuleWithMemoryExMOD(Chain, MaxConnections, initialBufferSize, local, OnConnect, OnDisconnect, OnReceive, OnInterrupt, OnSendOK, 0, ServerUserMappedMemorySize, SessionUserMappedMemorySize)
|
||||
|
||||
|
||||
size_t ILibAsyncServerSocket_GetConnections(ILibAsyncServerSocket_ServerModule server, ILibAsyncServerSocket_ConnectionToken *connections, size_t connectionsSize);
|
||||
void *ILibAsyncServerSocket_GetUser(ILibAsyncServerSocket_ConnectionToken *token);
|
||||
|
||||
void *ILibAsyncServerSocket_GetTag(ILibAsyncServerSocket_ServerModule ILibAsyncSocketModule);
|
||||
void ILibAsyncServerSocket_SetTag(ILibAsyncServerSocket_ServerModule ILibAsyncSocketModule, void *user);
|
||||
int ILibAsyncServerSocket_GetTag2(ILibAsyncServerSocket_ServerModule ILibAsyncSocketModule);
|
||||
|
||||
Reference in New Issue
Block a user