ChatMessage not working

Posted by Mr.lundmark on Sat 23 Oct 2010 09:52 AM — 11 posts, 40,006 views.

#0
Hey!

I've set up a chat connection using
ChatAcceptCalls(23)

and

ChatCall("localhost", 23)

Once that is done, I try to iterate through all the connection id's we have and:
ChatMessage(id, 7, "Test")

That message is never received on the other user's OnPluginChatMessage. I'm currently connecting to my own computer from one mushclient to another. I'm using python-scripting for this.
#1
I've tried connecting from one computer to another, still not working.
#2
Is your router/firewall blocking it?
#3
It shouldn't, since it allows connections to go through. It also allows disconnect-messages to go through. Everything is set up fine except the passing of messages.
Australia Forum Administrator #4
You found a bug, introduced in version 4.62 which had a lot of code cleanups for plugins.

Due to the way it was calling the plugins it assumed that your attempt to send a message was being rejected. You may have also noticed that even without using plugins no messages were appearing when you started chat sessions.

Fixed, I hope, in version 4.65
#5
I think you managed to solve the bug Nick, awesome!

However, directly afterwards I think I found another bug.

My client (not the server) crashes upon connecting to the server.

I can actually see the log though:
Calling server at 127.0.0.1 port 23
Session established to localhost.

And then it crashes :/

Want me to supply the code?
#6
I narrowed down the crash.

It's when I add this code:


def OnPluginChatDisplay(message, text):
	world.Note("OnPluginChatDisplay, message: " + str(message) + " text : " + str(text))
	return True
Amended on Sun 24 Oct 2010 07:17 AM by Mr.lundmark
#7
OnPluginChatMessage seems to work much better though.
Netherlands #8
Try returning 0, or alternatively, 1.

Something in combination with Python, MUSHclient and the WSH means random errors if you return certain values. For example, in the past I have experienced crashes when not sending a return value back, but setting an explicit 0 return magically fixed it.

Whether it is a bug in Python, a bug in MUSHclient, or some weird no-mans-land of developers reading the APIs differently, I don't know, but that might very likely fix it.

But for now, try to stick to ints. And strings for callbacks wanting strings back.
#9
Yeah that seems to solve it.

I don't understand why one function works with booleans while the other require ints?
Australia Forum Administrator #10
The partial answer is that the hard-coded calls use the type definitions in the .ODL file, for example:


[id(188)] long ChatGroup(BSTR Group, BSTR Message, BOOL Emote);


Now in this case I presume Python would enforce that you get back a long and not something else.

But the plugin callbacks use a "generic" caller (one that takes a VARIANT result I think) so they are more accepting of the data type you return. However I think Python still requires *some* sort of returned result, whereas other script languages may default to a NULL variant if you don't supply anything explicitly.

To be honest, I find the WSH interface quite confusing. Finding documentation on it is hard enough.