-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchannel.cpp
More file actions
38 lines (31 loc) · 790 Bytes
/
channel.cpp
File metadata and controls
38 lines (31 loc) · 790 Bytes
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
#include <QDebug>
#include <string.h>
#include "channel.h"
Channel::Channel()
{
}
Channel::~Channel()
{
}
void Channel::putMsg(AvatarSpirit *sender, AvatarSpirit *receiver, const State_Info_Header *stif)
{
struct Message msg;
msg.sender = sender;
msg.receiver = receiver;
msg.data = (char *) malloc(stif->size);
memcpy(msg.data, stif, stif->size);
msg_pool.append(msg);
}
void Channel::dispatchMsg()
{
// qDebug() << msg_pool.size() << "msgs to be dispatched...";
for (QList<Message>::iterator mit = msg_pool.begin(); mit != msg_pool.end(); ++mit)
{
AvatarSpirit *recver = mit->receiver;
recver->recvMsg((State_Info_Header *) mit->data);
// free data
free(mit->data);
}
// clear msgs
msg_pool.clear();
}