[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Bug reports
. . -> [Subject]  5.03 causing json issues

5.03 causing json issues

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Kahenraz   (75 posts)  [Biography] bio
Date Sat 08 Oct 2016 09:06 PM (UTC)

Amended on Sat 08 Oct 2016 09:08 PM (UTC) by Kahenraz

Message
I updated from 4.94 to 5.03 today and have started getting the following JSON error spam from GMCP:

GMCP DATA ERROR: C:\data\games\Mush\lua\json\decode\state.lua:151: Value set when one already in slot

GMCP DATA ERROR: C:\data\games\Mush\lua\json\decode\util.lua:35: unexpected character @ character: 2 0:2 [l] line:
[l

GMCP DATA ERROR: C:\data\games\Mush\lua\json\decode\util.lua:35: unexpected character @ character: 2 0:2 [v] line:
[v
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sat 08 Oct 2016 09:38 PM (UTC)
Message
On what MUD? I just tested on Aardwolf (which uses GMCP heavily) without any problems.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Kahenraz   (75 posts)  [Biography] bio
Date Reply #2 on Sun 09 Oct 2016 12:24 PM (UTC)
Message
I've sent you an e-mail with a zip file containing screenshots and a plugin which outputs the incoming packets.

There is a definite disparity between 4.94 and 5.03 which may be causing these issues.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sun 09 Oct 2016 08:03 PM (UTC)
Message
Which MUD? You could copy/paste the text of what you see into a reply. Screenshots of text aren't usually that helpful.

The screenshots don't show that error message anywhere.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Kahenraz   (75 posts)  [Biography] bio
Date Reply #4 on Mon 10 Oct 2016 02:30 AM (UTC)
Message
Materia Magica.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Tue 11 Oct 2016 04:52 AM (UTC)
Message

function OnPluginPacketReceived (s)
   print(s)
   
   print("------------------------------")
   
   return s
end -- function


I don't think it is wise to start introducing newlines into the output window when you receive a packet. This could have weird side-effects. That callback was really for manipulating packet data (eg. getting rid of carriage-returns) not for triggering displays on the output window.

Does this problem go away with the plugin removed?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Kahenraz   (75 posts)  [Biography] bio
Date Reply #6 on Tue 11 Oct 2016 05:05 AM (UTC)
Message
I think it was an error in how I was handling a string.gsub which sometimes inserted a newline in the middle of a json block depending on how packets were received.

I've disabled this plugin for now pending further thought on how to implement this.

It's relayed to the same issue another user had with his implementation:

https://gammon.com.au/forum/bbshowpost.php?bbsubject_id=8476

MM does not guarantee that a newline will arrive at the end of the packet with the prompt or something.

If I understand it correctly, I think the prompt arrives as {prompt}{json}{\n} where the newline is appended after the json. But sometimes the packet splits in the middle of the json which causes problems. The prompt isn't guaranteed to arrive in a complete packet.

Configure MUSHclient to convert an IAC EOR/GA to a newline doesn't work in this case so I've been looking into OnPluginPacketReceived().

I would say that this is not a bug as I had thought.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Tue 11 Oct 2016 08:18 AM (UTC)
Message
A more sophisticated OnPluginPacketReceived would look for newlines. That is, it would take the incoming packet, break it into "lines" and assemble an outgoing packet (with changes as required). Then any left over can be held over (ie. in an "extra" variable).

Next time OnPluginPacketReceived is called you prepend the "extra" variable (which after all was not sent to the client before) and repeat the process. That way, you never split a line.

There were some changes in version 4.99 (see release notes point 1) which are more likely to be the cause of the issue.

http://www.gammon.com.au/scripts/showrelnote.php?version=4.99&productid=0

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Tue 11 Oct 2016 09:10 PM (UTC)

Amended on Wed 12 Oct 2016 02:49 AM (UTC) by Nick Gammon

Message
Something like this will handle partial lines (untested though):



partial = ""  -- partial line from last time through

function OnPluginPacketReceived (s)

  -- add packet to what we already have (excluding carriage-returns)
  
  partial = partial .. s
  
  t = {}  -- table of lines to be returned
  
  -- iterate over each line
  
  partial = string.gsub (partial, "(.-)\n", 
    function (line) 
      table.insert (t, line)
      return ""
    end)

  if table.getn (t) > 0 then
    table.insert (t, "")  -- to get final linefeed
  end -- if
    
  -- return table of lines, concatenated with newlines between each one
  return table.concat (t, "\n")
  
end -- function OnPluginPacketReceived


That keeps left-over data from the previous packet in the variable "partial" (partial line). It then adds the current packet to the end. The new combined packet is then broken down at line-breaks by the string.gsub, and put into a table.

Now you could examine the table and make changes to individual lines.

Finally we return as the processed packet the table, concatenated together with newlines so it looks similar to the original. Any left-over data will be in "partial" for next time around.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


22,217 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]