using the second overload for .SendToAll

46 views
Skip to first unread message

sci

unread,
Jun 20, 2010, 12:35:32 PM6/20/10
to lidgren-network
Hi,

I'm wondering if there is a example for the second overload
for .SendToAll? what i'm trying to do is send a message to a server
and have the server broadcast it to everyone except the original
sender. If there is a example could someone point me at it please?

Many thanks,
Sci

Matthew Overall

unread,
Jun 20, 2010, 2:56:58 PM6/20/10
to lidgren...@googlegroups.com
// check if any messages has been received
NetMessageType type;
NetConnection sender;

while (server.ReadMessage(bufferReader, out type, out sender))
{
 switch (type)
{
case NetMessageType.Data:
// A client sent this data!
string msg = bufferReader.ReadString();

NetBuffer sendBuffer = server.CreateBuffer();
sendBuffer.Write((byte)PacketTypes.ChatMessage);
sendBuffer.Write(msg);

// send to everyone except sender
server.SendToAll(sendBuffer, NetChannel.ReliableInOrder1);.
break;
}
}



--
You received this message because you are subscribed to the Google Groups "lidgren-network" group.
To post to this group, send email to lidgren...@googlegroups.com.
To unsubscribe from this group, send email to lidgren-netwo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/lidgren-network?hl=en.


Matthew Overall

unread,
Jun 20, 2010, 2:57:32 PM6/20/10
to lidgren...@googlegroups.com
//ahh forgot to replace the line with this one.
server.SendToAll(sendBuffer, NetChannel.ReliableInOrder1,sender);

sci

unread,
Jun 20, 2010, 8:09:26 PM6/20/10
to lidgren-network
ah so that's what I had to put there ^^; thanks Matthew.

On Jun 20, 7:57 pm, Matthew Overall <matthew.over...@gmail.com> wrote:
> //ahh forgot to replace the line with this one.
> server.SendToAll(sendBuffer, NetChannel.ReliableInOrder1,sender);
>
> On Sun, Jun 20, 2010 at 12:56 PM, Matthew Overall <matthew.over...@gmail.com
> >> lidgren-netwo...@googlegroups.com<lidgren-network%2Bunsubscribe@ googlegroups.com>
> >> .
Reply all
Reply to author
Forward
0 new messages