Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Helper functions for broadcasts to all clients and sends to single clients
- * WORK NEEDED: investigate using templates to reduce the number of functions needed
- * send<type1, type2, type3>(a, b, c)
- **/
- void ClientManager::broadcast(Command cmd)
- {
- TRAVERSE_AND_LOCK()
- myClient->getConnection()->send(cmd);
- myClient->getConnection()->send((u32int)0);
- UNLOCK_TRAVERSE_END()
- }
- void ClientManager::send(ClientInstance^ c, Command cmd)
- {
- c->getSendLock();
- c->getConnection()->send(cmd);
- c->getConnection()->send((u32int)0);
- c->releaseSendLock();
- }
- void ClientManager::broadcast(Command cmd, u32int u)
- {
- TRAVERSE_AND_LOCK()
- myClient->getConnection()->send(cmd);
- myClient->getConnection()->send((u32int)4);
- myClient->getConnection()->send(u);
- UNLOCK_TRAVERSE_END()
- }
- void ClientManager::send(ClientInstance^ c, Command cmd, u32int u)
- {
- c->getSendLock();
- c->getConnection()->send(cmd);
- c->getConnection()->send((u32int)4);
- c->getConnection()->send(u);
- c->releaseSendLock();
- }
- void ClientManager::broadcast(Command cmd, System::String^ s)
- {
- TRAVERSE_AND_LOCK()
- myClient->getConnection()->send(cmd);
- myClient->getConnection()->send((u32int)(4+s->Length));
- myClient->getConnection()->send(s);
- UNLOCK_TRAVERSE_END()
- }
- void ClientManager::send(ClientInstance^ c, Command cmd, System::String^ s)
- {
- c->getSendLock();
- c->getConnection()->send(cmd);
- c->getConnection()->send((u32int)(4+s->Length));
- c->getConnection()->send(s);
- c->releaseSendLock();
- }
- void ClientManager::send(ClientInstance^ c, Command cmd, System::String^ s1, u32int i2)
- {
- c->getSendLock();
- c->getConnection()->send(cmd);
- c->getConnection()->send((u32int)(8+s1->Length));
- c->getConnection()->send(s1);
- c->getConnection()->send(i2);
- c->releaseSendLock();
- }
- void ClientManager::broadcast(Command cmd, float f)
- {
- TRAVERSE_AND_LOCK()
- myClient->getConnection()->send(cmd);
- myClient->getConnection()->send((u32int)4);
- myClient->getConnection()->send(f);
- UNLOCK_TRAVERSE_END()
- }
- void ClientManager::send(ClientInstance^ c, Command cmd, float f)
- {
- c->getSendLock();
- c->getConnection()->send(cmd);
- c->getConnection()->send((u32int)4);
- c->getConnection()->send(f);
- c->releaseSendLock();
- }
- void ClientManager::broadcast(Command cmd, u32int u, System::String^ s)
- {
- TRAVERSE_AND_LOCK()
- myClient->getConnection()->send(cmd);
- myClient->getConnection()->send((u32int)(8+s->Length));
- myClient->getConnection()->send(u);
- myClient->getConnection()->send(s);
- UNLOCK_TRAVERSE_END()
- }
- void ClientManager::send(ClientInstance^ c, Command cmd, u32int u, System::String^ s)
- {
- c->getSendLock();
- c->getConnection()->send(cmd);
- c->getConnection()->send((u32int)(8+s->Length));
- c->getConnection()->send(u);
- c->getConnection()->send(s);
- c->releaseSendLock();
- }
- void ClientManager::broadcast(Command cmd, u32int u1, u32int u2)
- {
- TRAVERSE_AND_LOCK()
- myClient->getConnection()->send(cmd);
- myClient->getConnection()->send((u32int)8);
- myClient->getConnection()->send(u1);
- myClient->getConnection()->send(u2);
- UNLOCK_TRAVERSE_END()
- }
- void ClientManager::send(ClientInstance^ c, Command cmd, u32int u1, u32int u2)
- {
- c->getSendLock();
- c->getConnection()->send(cmd);
- c->getConnection()->send((u32int)8);
- c->getConnection()->send(u1);
- c->getConnection()->send(u2);
- c->releaseSendLock();
- }
- void ClientManager::send(ClientInstance^ c, Command cmd, u32int u1, System::String^ s, u32int u2)
- {
- c->getSendLock();
- c->getConnection()->send(cmd);
- c->getConnection()->send((u32int)(12+s->Length));
- c->getConnection()->send(u1);
- c->getConnection()->send(s);
- c->getConnection()->send(u2);
- c->releaseSendLock();
- }
- void ClientManager::broadcast(Command cmd, u32int u1, u32int u2, System::String^ s)
- {
- TRAVERSE_AND_LOCK()
- myClient->getConnection()->send(cmd);
- myClient->getConnection()->send((u32int)12+s->Length);
- myClient->getConnection()->send(u1);
- myClient->getConnection()->send(u2);
- myClient->getConnection()->send(s);
- UNLOCK_TRAVERSE_END()
- }
- void ClientManager::broadcast(Command cmd, u32int u1, u32int u2, u32int u3)
- {
- TRAVERSE_AND_LOCK()
- myClient->getConnection()->send(cmd);
- myClient->getConnection()->send((u32int)12);
- myClient->getConnection()->send(u1);
- myClient->getConnection()->send(u2);
- myClient->getConnection()->send(u3);
- UNLOCK_TRAVERSE_END()
- }
- void ClientManager::broadcast(Command cmd, u32int u1, u32int u2, System::String^ s3, u32int u4)
- {
- TRAVERSE_AND_LOCK()
- myClient->getConnection()->send(cmd);
- myClient->getConnection()->send((u32int)16+s3->Length);
- myClient->getConnection()->send(u1);
- myClient->getConnection()->send(u2);
- myClient->getConnection()->send(s3);
- myClient->getConnection()->send(u4);
- UNLOCK_TRAVERSE_END()
- }
- void ClientManager::broadcast(Command cmd, u32int u1, u32int u2, System::String^ s3, System::String^ s4)
- {
- TRAVERSE_AND_LOCK()
- myClient->getConnection()->send(cmd);
- myClient->getConnection()->send((u32int)16+s3->Length+s4->Length);
- myClient->getConnection()->send(u1);
- myClient->getConnection()->send(u2);
- myClient->getConnection()->send(s3);
- myClient->getConnection()->send(s4);
- UNLOCK_TRAVERSE_END()
- }
- void ClientManager::broadcast(Command cmd, u32int u1, u32int u2, System::String^ s3, System::String^ s4, System::String^ s5)
- {
- TRAVERSE_AND_LOCK()
- myClient->getConnection()->send(cmd);
- myClient->getConnection()->send((u32int)20+s3->Length+s4->Length+s5->Length);
- myClient->getConnection()->send(u1);
- myClient->getConnection()->send(u2);
- myClient->getConnection()->send(s3);
- myClient->getConnection()->send(s4);
- myClient->getConnection()->send(s5);
- UNLOCK_TRAVERSE_END()
- }
- void ClientManager::send(ClientInstance^ c, Command cmd, u32int u1, u32int u2, System::String^ s3, System::String^ s4)
- {
- c->getSendLock();
- c->getConnection()->send(cmd);
- c->getConnection()->send((u32int)16+s3->Length+s4->Length);
- c->getConnection()->send(u1);
- c->getConnection()->send(u2);
- c->getConnection()->send(s3);
- c->getConnection()->send(s4);
- c->releaseSendLock();
- }
- void ClientManager::send(ClientInstance^ c, Command cmd, u32int u1, u32int u2, System::String^ s3, u32int u4)
- {
- c->getSendLock();
- c->getConnection()->send(cmd);
- c->getConnection()->send((u32int)(16+s3->Length));
- c->getConnection()->send(u1);
- c->getConnection()->send(u2);
- c->getConnection()->send(s3);
- c->getConnection()->send(u4);
- c->releaseSendLock();
- }
- void ClientManager::send(ClientInstance^ c, Command cmd, u32int u1, u32int u2, System::String^ s)
- {
- c->getSendLock();
- c->getConnection()->send(cmd);
- c->getConnection()->send((u32int)(12+s->Length));
- c->getConnection()->send(u1);
- c->getConnection()->send(u2);
- c->getConnection()->send(s);
- c->releaseSendLock();
- }
- void ClientManager::send(ClientInstance^ c, Command cmd, u32int u1, u32int u2, u32int u3)
- {
- c->getSendLock();
- c->getConnection()->send(cmd);
- c->getConnection()->send((u32int)(12));
- c->getConnection()->send(u1);
- c->getConnection()->send(u2);
- c->getConnection()->send(u3);
- c->releaseSendLock();
- }
- void ClientManager::send(ClientInstance^ c, Command cmd, System::String^ s1, System::String^ s2, System::String^ s3, System::String^ s4 )
- {
- c->getSendLock();
- c->getConnection()->send(cmd);
- c->getConnection()->send((u32int)(16+s1->Length+s2->Length+s3->Length+s4->Length));
- c->getConnection()->send(s1);
- c->getConnection()->send(s2);
- c->getConnection()->send(s3);
- c->getConnection()->send(s4);
- c->releaseSendLock();
- }
- void ClientManager::send(ClientInstance^ c, Command cmd, System::String^ s1, System::String^ s2, System::String^ s3 )
- {
- c->getSendLock();
- c->getConnection()->send(cmd);
- c->getConnection()->send((u32int)(12+s1->Length+s2->Length+s3->Length));
- c->getConnection()->send(s1);
- c->getConnection()->send(s2);
- c->getConnection()->send(s3);
- c->releaseSendLock();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement