Bug - Fixed "You are now in away mode, chat will update more slowly until you say something."

roippi

Developer
Some testing reveals some behaviors:

- If I have chat GUI open but no relay chat, mafia will not enter away mode because the event "You are now in away mode..." never happens. Even if you use the /afk command, this event doesn't happen.
- If GUI and (modern) relay chat are both open and away mode is entered, a chat message sent in the GUI will NOT trigger the "Welcome back!" message, meaning mafia stays in away state. Notably if I send a message in mafia, then go to relay chat and send a message, I won't get the "Welcome back!" message, meaning that as far as the server is concerned we are no longer in afk state - we just missed the event, however it is generated.

edit: ah, ninja'd...
 

Veracity

Developer
Staff member
- If I have chat GUI open but no relay chat, mafia will not enter away mode because the event "You are now in away mode..." never happens. Even if you use the /afk command, this event doesn't happen.
Works for me if you are really idle for 15 minutes; the poller notices that nothing has been sent, broadcasts the event itself, and starts polling with afk=1 with a bigger delay.

If GUI and (modern) relay chat are both open and away mode is entered, a chat message sent in the GUI will NOT trigger the "Welcome back!" message, meaning mafia stays in away state.
How peculiar. Again, that worked in my testing.

Edit: OK, I see what you mean.

- I open chat GUI
- I open mchat in browser
- In browser, I type /afk.
- KoL responds with mchat event saying you are away, which echoes in browser AND in GUI
- I type something in the GUI, which generates the local event using lchat protocol and does not send anything to KoL, since there is no way that I know for the lchat client to generate an "event" - and KoL does not generate an mchat event for the browser.
- the GUI starts polling with afk=0, which tells KoL it is not "away".
- When the browser polls again, if gets the lchat message I submitted - complete with a smaller delay, since KoL is not in "away" mode any more.

I don't see a solution for that. I think it is a KoL bug that it doesn't generate a "Welcome back" event for mchat if another lchat client says "afk=0", but I am quite sure that KoL's chat server is not coded to expect multiple clients with different protocols. It DOES have the "lasttime" field in the poll request for both protocols, which is why we can have two clients both polling with their own idea of what they've received, but propagating an lchat "event" into an mchat "event"? Nope.

I suppose that since we know that KoL won't propagate this, when we proxy the mchat poll, we could insert an event into the message array that KoL returns, just as we do for GUI-instigated private messages, which similarly have no KoL response.

I'm not sure that's worth the coding effort.
 
Last edited:

roippi

Developer
Here are my steps:

- Fire up mafia. Open chat GUI.
- Open relay browser, enter "modern" chat
- Execute "/afk" in the GUI. KoL responds with a "you are in away mode" event, as expected.
- In mafia's GUI, send myself a message. KoL does not respond with a "Welcome Back!" message, unexpectedly.
- Doing anything in the relay chat no longer responds with a "Welcome Back!" message. I think. A little unclear on this step, I think some timing may be involved. Investigating.
 

Veracity

Developer
Staff member
You were ninja'd again. That's the problem with editing existing messages, rather than posting new ones. Which is why I generally have no issue with double posting...
 

roippi

Developer
the GUI starts polling with afk=0, which tells KoL it is not "away".

Are you sure of this step? I attached a listener to ChatPoller.setPaused() and it is not fired after sending a chat message in the GUI after being put into "away" state. I could just be looking in the wrong place, of course.
 

Veracity

Developer
Staff member
I see no ChatPoller.setPaused in the current codebase. I see ChatPoller.pause and ChatPoller.unpause. The latter is called by ChatPoller.sentMessage. Here is the function:

Code:
	private void unpause( final boolean mchat )
	{
		if ( this.paused )
		{
			this.paused = false;
			this.delay = mchat ? ChatPoller.MCHAT_DELAY_NORMAL : ChatPoller.LCHAT_DELAY_NORMAL;
			if ( !mchat )
			{
				// mchat gives us the BACK message as an event
				EventMessage message = new EventMessage( ChatPoller.BACK_MESSAGE, "green" );
				ChatManager.broadcastEvent( message );
			}
		}
	}
If you see the GUI generate the "Welcome back" message, as you can see, paused must be false...
 

roippi

Developer
Oh wow, I wonder if I needed to svn update. That would be awkward. On mobile now, can check in a half hour.
 

Veracity

Developer
Staff member
I have confirmed this with a DEBUG log. Things with "j=1" are mchat requests from the browser. Otherwise, they are lchat messages from the GUI.

In mchat, type /afk:

Requesting: http://www.kingdomofloathing.com/submitnewchat.php?j=1&pwd&playerid=115875&graf=%2Fclan+%2Fafk
Retrieved: http://www.kingdomofloathing.com/submitnewchat.php?j=1&pwd&playerid=115875&graf=%2Fclan+%2Fafk
{"output":"","msgs":[]}

mchat polls:

Requesting: http://www.kingdomofloathing.com/newchatmessages.php?j=1&lasttime=1387548216
Retrieved: http://www.kingdomofloathing.com/newchatmessages.php?j=1&lasttime=1387548216
{"msgs":[{"type":"event","msg":"You are now in away mode, chat will update more slowly until you say something.","notnew":1,"time":1412459850}],"last":"1387548216","delay":10000}

It gets the "you are in away mode" event. With delay = 10000

...

Time passes. It polls:

Requesting: http://www.kingdomofloathing.com/newchatmessages.php?j=1&lasttime=1387548234
Retrieved: http://www.kingdomofloathing.com/newchatmessages.php?j=1&lasttime=1387548234
{"msgs":[],"last":"1387548247","delay":10000}

Nothing new. delay is still 10000.

In the GUI, I type "I am back"

Requesting: http://www.kingdomofloathing.com/submitnewchat.php?pwd&playerid=115875&graf=%2Fclan+I+am+back
Retrieved: http://www.kingdomofloathing.com/submitnewchat.php?pwd&playerid=115875&graf=%2Fclan+I+am+back
<font color=green>[clan]</font> <b><a target=mainpane href="showplayer.php?who=115875"><font color=black>Brianna</font></a>:</b> I am back<br>

KoL gives us the formatted message. The GUI polls again with afk=0.

Requesting: http://www.kingdomofloathing.com/newchatmessages.php?lasttime=1387548247&afk=0
Retrieved: http://www.kingdomofloathing.com/newchatmessages.php?lasttime=1387548247&afk=0
<!--lastseen:1387548274-->

Eventually, mchat polls again.

Requesting: http://www.kingdomofloathing.com/newchatmessages.php?j=1&lasttime=1387548247
Retrieved: http://www.kingdomofloathing.com/newchatmessages.php?j=1&lasttime=1387548247
{"msgs":[{"msg":"I am back","type":"public","mid":"1387548267","who":{"name":"Brianna","id":"115875","color":"black"},"format":"0","channel":"clan","channelcolor":"green","time":"1412459885"}],"last":"1387548274","delay":3000}

It gets the message I had typed in the GUI - and the delay is down to 3000 again, since we are no longer in away mode.

THAT "msg" array is where we could insert a pseudo event at the beginning.

{"type":"event","msg":"Welcome back! Away mode disabled.","notnew":1,"time":1412459850}

... which would induce the browser to print it in green before printing the other new messages.
 

roippi

Developer
Yeah I'm a big dumbhead from dumbville, I was working off an older version of ChatPoller. Thus why you were unable to reproduce many of my behaviors. Sorry about creating extra work for you.

r14802 slides in a clickable message to the chat GUI when you're away. I might tweak the styling of it a bit.
 

Veracity

Developer
Staff member
No problem. I think you'll agree that the final version is much cleaner.

Very nice! I just wanted to point out something I had changed since you last looked at things.

You used PreferenceListenerRegistry. I decided that that should really be just for preferences; there was no reason that every time we save the settings file that we should fire any listeners other than preferences, so things like (throne), (familiarlock), and such wouldn't need to be touched. So I implemented NamedListenerRegistry for things like that. I think you should use that for "[chatAway]". It's a trivial change. I'll just do it...
 

Nappa

Member
Today I've seen the message 'Server returned response code 502 for newchatmessages.php' twice in the CLI panel (r14803). Yesterday one as well if i remember correctly (r14798).

Since you;ve been tweaking around with the chat, could this be related? I don't remember that happening before.

(Only running the mafia chat pane, no chat open in the relay browser)
 

roippi

Developer
Today I've seen the message 'Server returned response code 502 for newchatmessages.php' twice in the CLI panel (r14803). Yesterday one as well if i remember correctly (r14798).

Since you;ve been tweaking around with the chat, could this be related? I don't remember that happening before.

(Only running the mafia chat pane, no chat open in the relay browser)

5xx error codes mean "internal server error" and the w3c recommends that clients display the error message to users. So nothing incorrect about that behavior.
 

Veracity

Developer
Staff member
Code:
Runnable in event dispatch thread
class java.lang.Exception: Runnable in event dispatch thread
java.lang.Exception: Runnable in event dispatch thread
	at net.sourceforge.kolmafia.StaticEntity.printStackTrace(StaticEntity.java:386)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:284)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:250)
	at net.sourceforge.kolmafia.chat.ChatSender.sendRequest(ChatSender.java:206)
	at net.sourceforge.kolmafia.chat.ChatSender.sendMessage(ChatSender.java:173)
	at net.sourceforge.kolmafia.chat.ChatSender.sendMessage(ChatSender.java:124)
	at net.sourceforge.kolmafia.swingui.ChatFrame$AwayPanel.mouseClicked(ChatFrame.java:573)
	at java.awt.Component.processMouseEvent(Component.java:6508)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
	at java.awt.Component.processEvent(Component.java:6270)
	at java.awt.Container.processEvent(Container.java:2229)
	at java.awt.Component.dispatchEventImpl(Component.java:4861)
	at java.awt.Container.dispatchEventImpl(Container.java:2287)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4501)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
	at java.awt.Container.dispatchEventImpl(Container.java:2273)
	at java.awt.Window.dispatchEventImpl(Window.java:2719)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
	at java.awt.EventQueue.access$200(EventQueue.java:103)
	at java.awt.EventQueue$3.run(EventQueue.java:694)
	at java.awt.EventQueue$3.run(EventQueue.java:692)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:708)
	at java.awt.EventQueue$4.run(EventQueue.java:706)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Runnable in event dispatch thread
 

roippi

Developer
Yeah should have made it implement Runnable and wrapped it in a RequestThread.runInParallel(this). Away from compy until late tonight.

(Also I should turn debugFoxtrotRemoval on so I see those stack traces too)
 

death star

New member
I'm used to running both mafia chat and relay browser chat, i found it very convenient.

Away mode interacts in unexpected, very annoying ways when both the chats are open.

I can see this is my fault for deeming convenient to run both chats at once. (no irony intended)

I'd still like to ask, are you planning on fixing that unfortunate interaction, or will that use of chat be labelled as deprecated from now on?

Also, no hope in asking for the option to disable away mode as a new mafia feature, right? :p
 

roippi

Developer
Away mode interacts in unexpected, very annoying ways when both the chats are open.

You know you could enumerate specific problems, or ask for specific changes, instead of vaguely saying there are some "annoying" (sigh) interactions.

I'd still like to ask, are you planning on fixing that unfortunate interaction

What interaction?

Also, no hope in asking for the option to disable away mode as a new mafia feature, right? :p

No.
 

death star

New member
Once i end up in away mode, i need to talk in both mafia and relay chat to take away away mode, else the other chat will still get those messages.

The messages get sent 2-3 times per minute. If i'm away only in the relay browser chat, i'll get repeated away messages followed by welcome back.

In addition to that, some messages are visualized only in mafia chat, not in the relay browser one.

screenshots added:
Cattura.PNG

Cattura.PNG

Sorry about that "annoying" word, i couldn't find a milder way to describe the experience; might be caused by the fact that english isn't my first language.
 
Last edited:

roippi

Developer
Which chat are you running in the browser simultaneously - "modern" or "older"? Which reversion are you running?

The behavior you're reporting is a bug, but we need to be able to reproduce it - which I cannot do, saying anything in the mafia GUI takes me out of away as expected - before we can address it.
 
Top