Greetings,
This is my first post on these forums because so far the community here has provided me with the answers to my questions without posting but it looks like I've ran in to an actual error.
Take this block of lua code:
--GMCP
local IAC, SB, SE, DO = 0xFF, 0xFA, 0xF0, 0xFD
local GMCP = 201
function Send_Telnet_Packet (what)
SendPkt (string.char (IAC, SB, GMCP)..what..string.char (IAC, SE))
end
function OnPluginTelnetSubnegotiation (msg_type, data)
if msg_type ~= GMCP then
return
end -- if not GMCP
CallPlugin("90523793cd3b6c150f7cb6fb",'parseGMCP',data)
end
needGMCPsetup = true
if IsConnected() and needGMCPsetup then
Send_Telnet_Packet ('Core.Supports.Set [ "Core 1", "Char 1", "Char.Name 1", "Char.Skills 1", "Char.Items 1", "Comm.Channel 1", "Redirect 1", "Room 1", "IRE.Rift 1", "IRE.Composer 1" ]')
needGMCPsetup = false
end
function OnPluginTelnetRequest (msg_type, data)
if msg_type == GMCP and data == "WILL" then
return true
end -- if
if msg_type == GMCP and data == "SENT_DO" then
Send_Telnet_Packet (string.format ('Core.Hello { "client": "MUSHclient", "version": "%s" }', Version ()))
Send_Telnet_Packet ('Core.Supports.Set [ "Core 1", "Char 1", "Char.Name 1", "Char.Skills 1", "Char.Items 1", "Comm.Channel 1", "Redirect 1", "Room 1", "IRE.Rift 1", "IRE.Composer 1" ]')
return true
end -- if ATCP login needed (just sent DO)
return false
end -- function OnPluginTelnetRequest
This is a GMCP implementation for IRE muds. This works just fine, however I'm trying to convert it to the python below:
def Send_Telnet_Packet (what):
world.SendPkt(u"\xff\xfa\xc9%s\xff\xf0"%(what))
def OnPluginTelnetSubnegotiation (msg_type, data):
if msg_type == 201:
parseGMCP(data)
return True
needGMCPsetup = True
if world.IsConnected and needGMCPsetup:
Send_Telnet_Packet ('Core.Supports.Set [ "Core 1", "Char 1", "Char.Name 1", "Char.Skills 1", "Char.Items 1", "Comm.Channel 1", "Redirect 1", "Room 1", "IRE.Rift 1", "IRE.Composer 1" ]')
needGMCPsetup = False
def OnPluginTelnetRequest (msg_type, data):
if msg_type == 201 and data == "WILL": return 1
if msg_type == 201 and data == "SENT_DO":
Send_Telnet_Packet ('Core.Hello { "client": "MUSHclient", "version": "%s" }'%world.Version)
Send_Telnet_Packet ('Core.Supports.Set [ "Core 1", "Char 1", "Char.Name 1", "Char.Skills 1", "Char.Items 1", "Comm.Channel 1", "Redirect 1", "Room 1", "IRE.Rift 1", "IRE.Composer 1" ]')
return 1
return 0
This causes freezing almost immediately. In particular the culprit (I've found through selective commenting) is OnPluginTelnetSubnegotiation, when I comment it out the freezing stops (although obviously so does the data). Even if I replace all the logic with return 1 it freezes. If I do return 0 it immediately disconnects on connection (which I would expect).
Sorry for my ugly code. Let me know if there's any further details you need from me. |