1
0
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:
Bryan Roe
2020-10-11 18:59:09 -07:00
parent e4d12f14c6
commit 17a487af68
3 changed files with 84 additions and 8 deletions

View File

@@ -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