broadcasting to hub

General adchpp discussion

Moderator: Moderators

Locked
newborn
Posts: 9
Joined: 2006-12-10 18:31

broadcasting to hub

Post by newborn » 2006-12-12 20:41

Well i'm fiddling around and not reallly knowing what I am doing !

At the moment when you use a command such as +test, you only see the message yourself. I would like to make it so that message is seen by all users.


I see

Code: Select all

local function reply(c, msg)
	answer = adchpp.AdcCommand(adchpp.CMD_MSG, adchpp.TYPE_INFO, adchpp.HUB_SID)
	answer:addParam(msg)
	c:send(answer)
end
and

Code: Select all


	if command == "test" then
		reply(c, "Test ok")
		return adchpp.DONT_SEND
and in the Protocol Draft,

2.3Message types

Message type specifies how messages should be routed, and thus which additional fields can be found in the message header. Clients should use the most limiting type, in terms of recipients, that makes sense for a particular message when sending it to the hub for distribution. Clients should disregard the message type when interpreting the message (after having parsed it). The following message types are defined:

B Broadcast. Hub must send message to all connected clients, including the sender of the message.

C Client message. Clients must use this message type when communicating directly over TCP.

D Direct message. The hub must send the message to the target_sid user.

E Echo message. The hub must send the message to the target_sid user and the my_sid user.

F Feature broadcast. The hub must send message to all clients that support both all required (+) and no excluded (-) features named. The feature name is matched against the corresponding SU field in INF sent by each client.

H Hub message. Clients must use this message type when a message is intended for the hub only.

I Info message. Hubs must use this message type when sending a message to a client that didn't come from another client.

U UDP message. Clients must use this message type when communicating directly over UDP.


so I guess this ties up with.

Code: Select all

-- Temporary fixes for SWIG 1.3.29
adchpp.TYPE_BROADCAST = string.char(adchpp.TYPE_BROADCAST)
adchpp.TYPE_DIRECT = string.char(adchpp.TYPE_DIRECT)
adchpp.TYPE_ECHO = string.char(adchpp.TYPE_ECHO)
adchpp.TYPE_FEATURE = string.char(adchpp.TYPE_FEATURE)
adchpp.TYPE_INFO = string.char(adchpp.TYPE_INFO)
adchpp.TYPE_HUB = string.char(adchpp.TYPE_HUB)
so I messed around with changing INFO to BROADCAST or HUB in this line of code

Code: Select all

answer = adchpp.AdcCommand(adchpp.CMD_MSG, adchpp.TYPE_INFO, adchpp.HUB_SID)
but im having no luck .......... :?

ivulfusbar
Posts: 506
Joined: 2003-01-03 07:33

Post by ivulfusbar » 2006-12-13 08:13

1) What message do you want everyone to see?
the +test message, or the reply that the hub/script generate in response to +test being written, or both?


Unless you clearify this, we can't help you.

ALWAYS, create a minimal example of what you want be done.
Everyone is supposed to download from the hubs, - I don´t know why, but I never do anymore.

VidFamne
Posts: 13
Joined: 2004-09-20 14:01

Post by VidFamne » 2006-12-13 12:09

I experiment a little with this;

Code: Select all

local function broadcastMsg(c, msg)

	answer = adchpp.AdcCommand(adchpp.CMD_MSG, adchpp.TYPE_BROADCAST, adchpp.HUB_SID)

	answer:addParam(msg)

	cm:sendToAll(answer)

end
Dont know if it is this you looking for, though. :)

newborn
Posts: 9
Joined: 2006-12-10 18:31

Post by newborn » 2006-12-13 13:22

ivulfusbar wrote:1) What message do you want everyone to see?
the +test message, or the reply that the hub/script generate in response to +test being written, or both?


Unless you clearify this, we can't help you.

ALWAYS, create a minimal example of what you want be done.

the reply that the hub/script generates in response

newborn
Posts: 9
Joined: 2006-12-10 18:31

Post by newborn » 2006-12-13 13:29

VidFamne wrote:I experiment a little with this;

Code: Select all

local function broadcastMsg(c, msg)

	answer = adchpp.AdcCommand(adchpp.CMD_MSG, adchpp.TYPE_BROADCAST, adchpp.HUB_SID)

	answer:addParam(msg)

	cm:sendToAll(answer)

end
Dont know if it is this you looking for, though. :)

wooohoooo, perfect. That works a treat. Thanks matey.

Locked