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

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Bug reports
. . -> [Subject]  ColourNote called from within OnPluginTelnetSubnegotiation

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: ColourNote called from within OnPluginTelnetSubnegotiation
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Kevnuke   USA  (83 posts)  [Biography] bio
Date Fri 17 Feb 2012 06:44 PM (UTC)  quote  ]
Message
Thanks for the explanation, Nick. I just got the memo because I forgot to subscribe to this thread lol.

Holy crap! Working on a Mac really screwed me up! I got used to using the scroll wheel on my mouse in the reverse direction in the 4 days that I couldn't use my laptop..
[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Mon 09 Jan 2012 05:57 AM (UTC)  quote  ]
Message
Kevnuke said:

I got a basic GMCP plugin working that simply notes the output of messages to the output window. It works as expected, except for one thing. The background color of ColourNote I use to show the GMCP messages is getting applied to some of the text that it shouldn't be.


Doing a ColourNote during telnet negotiation may lead to strange results. You are injecting a new line into what might be a partial line received from the MUD.

If you must do this, I would queue it up (eg. with DoAfterNote) and have it appear in a more orderly way.

- Nick Gammon

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

Posted by Kevnuke   USA  (83 posts)  [Biography] bio
Date Sun 08 Jan 2012 09:42 PM (UTC)  quote  ]
Message
Twisol said:

Links and images are tags reserved for forum admins, which basically just means Nick.


Thanks, good to know.

Twisol said:

I'm not really sure why ColourNote is doing that, to be honest...


Well if anything my little experiment maybe discovered a bug?
[Go to top] top

Posted by Twisol   USA  (2,230 posts)  [Biography] bio
Date Sun 08 Jan 2012 09:33 PM (UTC)  quote  ]
Message
Links and images are tags reserved for forum admins, which basically just means Nick.

I'm not really sure why ColourNote is doing that, to be honest...

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Kevnuke   USA  (83 posts)  [Biography] bio
Date Sun 08 Jan 2012 08:59 PM (UTC)  quote  ]

Amended on Sun 08 Jan 2012 09:01 PM (UTC) by Kevnuke

Message
Here are the screenshots for what I was talking about.

http://imageshack.us/g/502/achaea03.jpg/

What's the forum code for a hyperlink?.. I didn't see it in the link.
[Go to top] top

Posted by Twisol   USA  (2,230 posts)  [Biography] bio
Date Sat 07 Jan 2012 08:22 AM (UTC)  quote  ]
Message
Kevnuke said:
Because I'm going to have everything done in a single plugin, it doesn't need to broadcast. I wanted to see the unmodified message from the server. It's more of a personal project to improve my Lua skills. Such as how to take the server output and put it into useable tables and other variables. I saw you do it in the plugin but I wanted to understand it well enough to recreate it myself.

Fair enough. Just keep in mind it probably won't cooperate other plugins that need GMCP, whether you release yours for other people to use, or you install other peoples' plugins.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Kevnuke   USA  (83 posts)  [Biography] bio
Date Sat 07 Jan 2012 05:49 AM (UTC)  quote  ]
Message
Because I'm going to have everything done in a single plugin, it doesn't need to broadcast. I wanted to see the unmodified message from the server. It's more of a personal project to improve my Lua skills. Such as how to take the server output and put it into useable tables and other variables. I saw you do it in the plugin but I wanted to understand it well enough to recreate it myself.

I'll post screenshots when I'm on my computer.
[Go to top] top

Posted by Twisol   USA  (2,230 posts)  [Biography] bio
Date Sat 07 Jan 2012 05:40 AM (UTC)  quote  ]
Message
Kevnuke said:
..how do I upload screenshots?

Upload them to a service like imageshack.us, and post the link.

I have to ask, why are you modifying the original GMCP plugin? It's meant to emit data for other plugins to use, not to be directly modified itself. Also, there's a GMCP DEBUG alias in the original that toggles debug output, displaying GMCP data as it comes in.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Kevnuke   USA  (83 posts)  [Biography] bio
Date Sat 07 Jan 2012 05:26 AM (UTC)  quote  ]
Message
I got a basic GMCP plugin working that simply notes the output of messages to the output window. It works as expected, except for one thing. The background color of ColourNote I use to show the GMCP messages is getting applied to some of the text that it shouldn't be.

Here is the relevant piece of the plugin..

Version 4.80


<script>
<![CDATA[

require("json")
require("tprint")

-- GMCP and Telnet Request/Subnegotiation info
local CLIENT_ID = {client="MUSHclient", version=Version()}
local codes = {
  IAC_SB_GMCP = "\255\250\201", -- begins a GMCP packet
  IAC_SE      = "\255\240",     -- ends a GMCP packet
  GMCP        = 201,            -- GMCP protocol number
}
local SB_GMCP = codes.IAC_SB_GMCP .. "%s" .. codes.IAC_SE

-- GMCP modules supported by this plugin
local GMCP_options = {
  "Core 1",
  "Char 1",
  "Char.Skills 1",
  "Char.Items 1",
  "Comm.Channel 1",
  "Room 1",
  "Redirect 1",
  "IRE.Rift 1",
  "IRE.Composer 1",
}

function SendGMCP(message, content)
  if type(message) ~= "string" then
    return nil, "Message name must be a string."
  end
  
  if content ~= nil then
    content = json.encode({content})
    if content == nil then
      return nil, "Invalid input."
    end
    message = ("%s %s"):format(message, content:sub(2, #content-1))
  end
  
  SendPkt(SB_GMCP:format(message))
  return true
end

function OnPluginTelnetRequest (opt, data)
  if opt ~= 201 then
    return false
  end
  
  if data == "SENT_DO" then
    Note("GMCP enabled.\n")
    
    SendGMCP("Core.Hello ", CLIENT_ID)
    SendGMCP("Core.Supports.Set ", GMCP_options)
  end
  
  return true
end

function OnPluginTelnetSubnegotiation (opt, data)
  if opt ~= codes.GMCP then
    return
  end

ColourNote ("blue", "white", data)
  
  local msg, content = unpack(utils.split(data, " ", 1))
  if not content or content:len() == 0 then
    content = nil
  else
    -- Not every JSON parser allows any top-level value to be valid.
    -- Ensuring that a non-object non-array value is at least within
    -- an array makes this code parser-agnostic.
    local err
    content, err = json.decode(("[%s]"):format(content))
    if content ~= nil then
      content = content[1]
    else
      error("Invalid message: " .. err)
    end
  end
  
function toggle_debug()
  gmcpdebug = not gmcpdebug
  Note(("GMCP Debugging is %s"):format(gmcpdebug and "Enabled" or "Disabled"))
end

]]>
</script>



..how do I upload screenshots?
[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.


1,341 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]