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

Gammon Forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  A problem i need to find a solution with Packet...
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

A problem i need to find a solution with Packet...

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


Posted by Maxhrk   USA  (76 posts)  [Biography] bio
Date Wed 09 May 2007 07:03 PM (UTC)
Message
I have a little problem here... My goal was to find if end of the packet have '\n'. (Is that for EF hex code or something different?.. i am unfamiliar with hex codes though!)

Anyway.. if it dont have \n then the packet will be added to packets table and will return packet null or ''. but if it do, then i will unpack packets to packet and then return packet.

it just one of my experiment to figure it about this OnPluginPacketRecieved feature.


..Lowe points no   0d 0a 4c 6f 77 65 20 70 6f 69 6e 74 73 20 6e 6f
rthwards....[32m   72 74 68 77 61 72 64 73 2e 0d 0a 1b 5b 33 32 6d
3223h,.[37m.[32m   33 32 32 33 68 2c 1b 5b 33 37 6d 1b 5b 33 32 6d
 4645m,.[37m.[32   20 34 36 34 35 6d 2c 1b 5b 33 37 6d 1b 5b 33 32
m 4408e,.[37m.[3   6d 20 34 34 30 38 65 2c 1b 5b 33 37 6d 1b 5b 33
2m 10p,.[37m.[32   32 6d 20 31 30 70 2c 1b 5b 33 37 6d 1b 5b 33 32
m 15015en,.[37m.   6d 20 31 35 30 31 35 65 6e 2c 1b 5b 33 37 6d 1b
[32m 22125w.[37m   5b 33 32 6d 20 32 32 31 32 35 77 1b 5b 33 37 6d
 ex-..             20 65 78 2d ff ef




function OnPluginPacketReceived (packet)
	if aDebug == true then
		if string.find(packet, "\n$") == nil then
			packetcount = packetcount + 1
			table.insert(packets,packet)
			packet = ''	
		else
			table.insert(packets,packet)
			packet = unpack(packets)
			ColourNote("red","black","packets count until endline:" .. packetcount)
			packetcount = 0
		end -- if
	end -- if
	
	return packet
end
[Go to top] top

Posted by Maxhrk   USA  (76 posts)  [Biography] bio
Date Reply #1 on Wed 09 May 2007 07:15 PM (UTC)

Amended on Wed 09 May 2007 07:52 PM (UTC) by Maxhrk

Message
I forgot to add something.. when my packet has returned.. it seem my Prompt Trigger has fired twice. Is that a bug or intentional? I thought probably because your mushclient read from both source from Onplugin and other. I am not sure really... bah.

EDIT: nevermind, i saw that my packettest plugin added prompt trigger.. it shouldn't.
[Go to top] top

Posted by Nick Gammon   Australia  (21,608 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Wed 09 May 2007 09:32 PM (UTC)
Message
You can easily find the last character in a string with string.sub, using a column number of -1. Using negative column numbers counts from the right.

http://www.gammon.com.au/scripts/doc.php?lua=string.sub

- Nick Gammon

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

Posted by Maxhrk   USA  (76 posts)  [Biography] bio
Date Reply #3 on Wed 09 May 2007 11:01 PM (UTC)

Amended on Thu 10 May 2007 12:56 AM (UTC) by Maxhrk

Message
thanks you.. it seem easy to do that.. last question for you.... how do you to hex code instead of oct code like FF/EF?

EDIT:

nevermind, i has to search google to go over to find RFCS for EF/FF.. it seem i find a DEC code for it... is there a completed document regards TELNET in general?
[Go to top] top

Posted by Maxhrk   USA  (76 posts)  [Biography] bio
Date Reply #4 on Thu 10 May 2007 12:52 AM (UTC)
Message
it work perfectly; however, it seem i learned that i can only return packet of 1024 chars.. athough it is an interesting experiment nevertheless. :D
[Go to top] top

Posted by Nick Gammon   Australia  (21,608 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Thu 10 May 2007 01:25 AM (UTC)

Amended on Thu 10 May 2007 01:26 AM (UTC) by Nick Gammon

Message

You can convert bases with most scientific calculators, or in Lua do this:


print (tonumber ("FF", 16)) --> 255


Given that FF is "really" 255 in decimal, you can now convert it to octal:


print (bit.tostring (255, 8)) --> 377


If you want to imbed hex FF into a string, one way is to use string.char:


ff = string.char (255)


Or, simply put the decimal number into the string:


ff = "\255"

- Nick Gammon

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

Posted by Nick Gammon   Australia  (21,608 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Thu 10 May 2007 01:39 AM (UTC)

Amended on Thu 10 May 2007 01:43 AM (UTC) by Nick Gammon

Message
Quote:

... it seem i learned that i can only return packet of 1024 chars ...


There is no such limitation that I am aware of. This small test correctly displays 40 lines of over 60 characters per line (over 2400 bytes), when it sees the word "east".

In fact, it will display 100 lines, without problem.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="big_packets_test"
   author="Nick Gammon"
   id="52e1fbe5776e6b029917910b"
   language="Lua"
   purpose="Testing OnPluginPacketReceived with big lines"
   date_written="2007-05-10"
   requires="3.59"
   version="1.0"
   >
</plugin>

<script>
function OnPluginPacketReceived (s)

  if string.match (s, "east") then
    for i = 1, 40 do
      s = s .. "\n" .. tostring (i) .. ": " .. string.rep ("-", 60)
    end -- for
  end -- if

  return s
 
end -- function OnPluginPacketReceived
</script>
</muclient>

Example output

say east
You say 'east'

<28/28hp 105/105m 110/110mv 1252/8748xp> 
1: ------------------------------------------------------------
2: ------------------------------------------------------------
3: ------------------------------------------------------------
4: ------------------------------------------------------------
5: ------------------------------------------------------------
6: ------------------------------------------------------------
7: ------------------------------------------------------------
8: ------------------------------------------------------------
9: ------------------------------------------------------------
10: ------------------------------------------------------------
11: ------------------------------------------------------------
12: ------------------------------------------------------------
13: ------------------------------------------------------------
14: ------------------------------------------------------------
15: ------------------------------------------------------------
16: ------------------------------------------------------------
17: ------------------------------------------------------------
18: ------------------------------------------------------------
19: ------------------------------------------------------------
20: ------------------------------------------------------------
21: ------------------------------------------------------------
22: ------------------------------------------------------------
23: ------------------------------------------------------------
24: ------------------------------------------------------------
25: ------------------------------------------------------------
26: ------------------------------------------------------------
27: ------------------------------------------------------------
28: ------------------------------------------------------------
29: ------------------------------------------------------------
30: ------------------------------------------------------------
31: ------------------------------------------------------------
32: ------------------------------------------------------------
33: ------------------------------------------------------------
34: ------------------------------------------------------------
35: ------------------------------------------------------------
36: ------------------------------------------------------------
37: ------------------------------------------------------------
38: ------------------------------------------------------------
39: ------------------------------------------------------------
40: ------------------------------------------------------------



- Nick Gammon

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

Posted by Nick Gammon   Australia  (21,608 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Thu 10 May 2007 01:45 AM (UTC)
Message
I should point out also that a newline can occur in the middle of a packet.

- 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.


4,716 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 FutureQuest]