Jump to content


Photo

Ether 1.1 - Network Library For Game Maker


  • Please log in to reply
85 replies to this topic

#1 PsichiX

PsichiX

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 24 May 2010 - 10:06 AM

Title: Ether - Network Library For Game Maker

Genre: Network Engine

Download: http://psichix.gmcla.../Ether_1100.zip
File size: 116 kb.

Authors:

Programming:

  • PsichiX - XenoN Core
  • Snake - GMapi


Description: Ether is a network library (based on XenoN Core Ether module and GMapi; also is a part of SixthSense :) ) for GameMaker, that contain features of most other libraries (like all-in-one dll). Supports sockets to network communication, buffers to store data, sessions for automated client-server communication (for multiplayer games primarily), HTTP requests to communicate with Web servers (asynchronous download/upload files and data from/to the server), and XML languages reader (HTML websites). Project file contain examples of each engine feature, and I'm working on other advanced examples.

TODO examples list:
  • files uploader using communication with sendspace
  • search engine using communication with google
  • data streaming to clients (movies, audio, etc.)

Edited by PsichiX, 27 December 2010 - 04:13 AM.

  • 4

#2 YellowAfterlife

YellowAfterlife

    GMC Member

  • Global Moderators
  • 3903 posts
  • Version:GM:Studio

Posted 24 May 2010 - 10:26 AM

Looks great. Everything in examples works.
Question 1: {Requests} use POST\GET methods?
Question 2: What is the licence for using this?
  • 0

#3 PsichiX

PsichiX

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 24 May 2010 - 10:35 AM

1.
for GET method use: EtSessionDownload(); or EtSessionDownloadAsync() and EtSessionDownloadProgress() [asynchronous mode];
for POST method use: EtSessionSendForm(); or EtSessionSendFormAsync() and EtSessionSendFormProgress() [asynchronous mode];
for other methods use: EtSessionRequest(); or EtSessionRequestAsync() and EtSessionRequestProgress() [asynchronous mode];
EtSessionSendForm*() and EtSessionRequest*() works like download example (some arguments are different - more info in function scripts)

2. totally free for commercial use :)

Edited by PsichiX, 24 May 2010 - 10:35 AM.

  • 1

#4 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 24 May 2010 - 01:17 PM

Looks great, but are there any more details available? Some descriptions of the words you used would be nice.

Can we expect better documentation?
Are sessions and requests mainly used for HTTP?
How are the packets structured?
Is GMAPI only used for callbacks (it seems)?

I noticed that 39DLL does have better buffer <-> file functions. You only have load and save. Also, there seems to be a problem with downloading the Google homepage.

Edited by TheMagicNumber, 24 May 2010 - 01:29 PM.

  • 0

#5 PsichiX

PsichiX

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 25 May 2010 - 08:47 AM

Can we expect better documentation?

yes, but i don't know when it will be done.

Are sessions and requests mainly used for HTTP?

Session types: Download, SendForm, Request use HTTP protocol, other functions are strictly userdefined protocols. Now i'm working on Mail (SMTP, POP3) protocol :lol:

How are the packets structured?

Socket send whole buffer at once, with size-header (if we don't know how much data trying to send and receive) or without size-header.
Game session send data like socket.
HTTP request session send data like socket but receive parts and flush them to buffer.
Now I'm working on sending splited parts of buffer, and receiving like in HTTP requests session, for sockets and game sessions.

Is GMAPI only used for callbacks (it seems)?

only for callbacks

I noticed that 39DLL does have better buffer <-> file functions. You only have load and save.

what functions I missed? ;)

Also, there seems to be a problem with downloading the Google homepage.

i will check this, thanks for information :D
  • 1

#6 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 25 May 2010 - 10:13 AM

39DLL can read from files somewhat like C can, it can read chunks of a file into the buffer. You can only read an entire file into the buffer with Ether.

I just saw EtBufferSetResize and EtBufferGetResize, what do these do?

By the way, if you want to keep your capitalizations, EtSocketGetUDPbuffSize and EtSocketSetUDPbuffSize should capitalize "buff". :lol:
  • 0

#7 PsichiX

PsichiX

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 25 May 2010 - 11:21 AM

39DLL can read from files somewhat like C can, it can read chunks of a file into the buffer. You can only read an entire file into the buffer with Ether.

Ether can read (and save) parts of files too. EtBufferLoad() (and EtBufferSave()) second argument is bytes offset and third argument is part size (0 mean read whole file) :lol:

I just saw EtBufferSetResize and EtBufferGetResize, what do these do?

default resizing buffer mode is adjust buffer space to needed size (if resize is 0), but if resize is more than 0 then buffer resize operation will reserve bonus memory space and when buffer space will be all filled then it will resize to bonus size again. example:
SetResize to 0:
step 1: [1][1][1][1]
step 2: [1][1][1][1][1][1][1][1]
step 3: [1][1][1][1][1][1][1][1][1][1][1][1]
SetResize to 8:
step 1: [1][1][1][1][0][0][0][0]
step 2: [1][1][1][1][1][1][1][1]
step 3: [1][1][1][1][1][1][1][1][1][1][1][1][0][0][0][0]
[1] - filled memory space
[0] - empty memory space
this feature allow to fast data writing. (memory block is reallocated not in each writing but only if whole memory space is filled)

By the way, if you want to keep your capitalizations, EtSocketGetUDPbuffSize and EtSocketSetUDPbuffSize should capitalize "buff". tongue.gif

good point ;P

Edited by PsichiX, 25 May 2010 - 11:25 AM.

  • 1

#8 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 25 May 2010 - 11:35 AM

You didn't have those parameters in the scripts I have, did you update it or something?

Same thing I did for my buffer in CanNet. :lol:
  • 0

#9 PsichiX

PsichiX

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 25 May 2010 - 11:38 AM

You didn't have those parameters in the scripts I have, did you update it or something?

oups :0 i forgot add them, sorry, today i will do this :lol:
  • 1

#10 PsichiX

PsichiX

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 28 May 2010 - 07:05 AM

Update to version 1.0.2.0!
Added missed arguments in EtSessionSend(), EtSocketSend(), EtBufferSave() and EtBufferLoad() scripts. Now You can send part of buffer, not only whole buffer data.

  • 1

#11 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 01 June 2010 - 08:05 PM

Do you think you can add HTML5 WebSocket support?
  • 0

#12 PsichiX

PsichiX

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 16 June 2010 - 06:30 AM

I was read something about this, and i think it is possible to add websocket support to new Ether version
  • 1

#13 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 17 June 2010 - 01:43 AM

Awesome! :D Looking forward to it.
  • 0

#14 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 22 June 2010 - 08:06 PM

I was just going to start making a websocket example, but I need to make the packets in a specific format. I need no formatting.

Question: How are packets formatted?


Found that, having problems detecting if a client lost connection, though.

Edited by TheMagicNumber, 22 June 2010 - 10:33 PM.

  • 0

#15 LoopStan

LoopStan

    North-See Developer

  • GMC Member
  • 1398 posts

Posted 22 June 2010 - 10:34 PM

Wow. This DLL seems to be feature rich, and the people that have used it, really like it. I will have to use this in my current project. Once I get the hang of it, and start to use it, i'll let you know how I feel about it from a person who isn't so good in this area.

EDIT : I've looked over it and ran the example, and it works really well! I do have a request though, is there a possibility of being able to remove the GMApi portion, so we can use it in other languages as well? Or would you rather keep it to gm.

Edited by LoopStan, 22 June 2010 - 10:55 PM.

  • 0

#16 PsichiX

PsichiX

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 23 June 2010 - 05:59 AM

There is special version of this lib for C++, based on Ether module of my XenoN Core engine. I will compile it without GMapi (for non-GM apps) today and you will get it tomorrow :)

Edited by PsichiX, 23 June 2010 - 06:10 AM.

  • 1

#17 LoopStan

LoopStan

    North-See Developer

  • GMC Member
  • 1398 posts

Posted 23 June 2010 - 09:01 PM

Thank you very much! This will help me a ton, since the current project I'm working on is split between Gm and C++. Can't wait!
  • 0

#18 PsichiX

PsichiX

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 24 June 2010 - 06:20 AM

Sorry, but yesterday I was too busy to make that, but today I will do this for sure :)
  • 1

#19 LoopStan

LoopStan

    North-See Developer

  • GMC Member
  • 1398 posts

Posted 17 August 2010 - 08:42 PM

Hey, can you release this without gmapi so i can use it in a c++ server for my game? Thanks :)
  • 0

#20 kalzme

kalzme

    GMC Member

  • GMC Member
  • 329 posts
  • Version:GM:Studio

Posted 18 August 2010 - 12:20 AM

can the xml parser read CDATA properly?
if so, how?

for example this:
<item>
<title><![CDATA[bla bla bla]]></title>            
</item>

i have already tried to read it like this:
EtXmlTagGet(xml, 'item#id:0/title/');
but that doesn't work.
  • 0

#21 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 18 August 2010 - 05:01 AM

I am certain EtXmlTagGet does not support "paths" to elements, you must do that yourself. Look at an example.
  • 0

#22 PsichiX

PsichiX

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 18 August 2010 - 05:10 AM

loopstan: i will try do this in this week
kaizme: i will add CDATA and comments tags parser.
  • 0

#23 kalzme

kalzme

    GMC Member

  • GMC Member
  • 329 posts
  • Version:GM:Studio

Posted 18 August 2010 - 09:40 AM

loopstan: i will try do this in this week
kaizme: i will add CDATA and comments tags parser.

thnx, that would be great!

I am certain EtXmlTagGet does not support "paths" to elements, you must do that yourself. Look at an example.

this is taken from the example & it works for me on normal tags with no CDATA in it..:
// set title tag value as window caption
room_caption = EtXmlTagGet(
                xml,                // XML element
                'html/head/title/'  // tag path (last '/' character is very important for setting/getting tags values! it's like trying to get unnamed tag - unnamed tags are values inside tags, for example: '<tag>value</tag>')
                )

  • 0

#24 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 18 August 2010 - 06:29 PM

I never saw that, thanks.
  • 0

#25 kalzme

kalzme

    GMC Member

  • GMC Member
  • 329 posts
  • Version:GM:Studio

Posted 20 August 2010 - 10:41 AM

btw, is there any way to read the response header fields?
e.g., Content-Length, Content-Type, Date etc.?
  • 0

#26 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Member
  • 9322 posts
  • Version:Unknown

Posted 22 August 2010 - 01:38 AM

@kalzme: Yeah. Send the request yourself with the sockets, then the response will include the headers.

@PsichiX: This is great, but I'm having some issues with the XML functions.

Firstly, does including the XML declaration (<?xml version="1.0" encoding="UTF-8"?>) in the beginning of the text cause problems with EtXmlParse? I'm getting the XML from a web server and I want to know if I should remove that before parsing.

Second, I'm wondering why my attempt to parse an XML document (received successfully from a web server via sockets) isn't working.

I have this format XML file (received from Twitter API with user info removed for privacy):

<?xml version="1.0" encoding="UTF-8"?>
<statuses type="array">
<status>
  <created_at>Sat Aug 21 04:06:53 +0000 2010</created_at>
  <id>21720949158</id>
  <text>[TWEET HERE]</text>
  <source>web</source>
  <truncated>false</truncated>
  <in_reply_to_status_id></in_reply_to_status_id>
  <in_reply_to_user_id></in_reply_to_user_id>
  <favorited>false</favorited>
  <in_reply_to_screen_name></in_reply_to_screen_name>
  <retweet_count></retweet_count>
  <retweeted>false</retweeted>
  <user>
    <id>6972182</id>
    <name>[USERNAME HERE]</name>
    <screen_name>[USER'S SCREEN NAME HERE]</screen_name>
    <location></location>
    <description></description>
    <profile_image_url>[USER'S PROFILE PIC URL HERE]</profile_image_url>
    <url>[USER'S PROFILE URL HERE]</url>
    <protected>false</protected>
    <followers_count>58719</followers_count>
    <profile_background_color>000000</profile_background_color>
    <profile_text_color>000000</profile_text_color>
    <profile_link_color>FF0099</profile_link_color>
    <profile_sidebar_fill_color>CCCCCC</profile_sidebar_fill_color>
    <profile_sidebar_border_color>000000</profile_sidebar_border_color>
    <friends_count>137</friends_count>
    <created_at>Wed Jun 20 17:02:52 +0000 2007</created_at>
    <favourites_count>0</favourites_count>
    <utc_offset>-18000</utc_offset>
    <time_zone>Eastern Time (US &amp; Canada)</time_zone>
    <profile_background_image_url>[USER'S PROFILE BACKGROUND IMAGE URL HERE]</profile_background_image_url>
    <profile_background_tile>false</profile_background_tile>
    <profile_use_background_image>true</profile_use_background_image>
    <notifications>false</notifications>
    <geo_enabled>false</geo_enabled>
    <verified>false</verified>
    <following>true</following>
    <statuses_count>2427</statuses_count>
    <lang>en</lang>
    <contributors_enabled>false</contributors_enabled>
    <follow_request_sent>false</follow_request_sent>
    <listed_count>1786</listed_count>
    <show_all_inline_media>false</show_all_inline_media>
  </user>
  <geo/>
  <coordinates/>
  <place/>
  <contributors/>
</status>
.
.
.
</statuses>

That said, when I try to get EtXmlTagExists(xml,"statuses/") (I've also tried without the ending slash), it returns 0, even though the first tag is clearly <statuses>. Am I doing something wrong?

-IMP ;) :)
  • 0

#27 PsichiX

PsichiX

    GMC Member

  • GMC Member
  • 399 posts
  • Version:GM:Studio

Posted 22 August 2010 - 10:13 AM

<statuses type="array">

this tag should looks like that:
<statuses type="array" />
because XML reader does not support old standard, but i see that some popular sites like twitter still use this (ehh ;0).
I will add this to next update, and reading <?xml?> too, because now reader parse only pure tags, even CDATA are not parsed, and CDATA will be readable soon :)

btw, is there any way to read the response header fields?

engine already does support this thing, i will add it to Ether.dll too.

Edited by PsichiX, 22 August 2010 - 10:15 AM.

  • 0

#28 kalzme

kalzme

    GMC Member

  • GMC Member
  • 329 posts
  • Version:GM:Studio

Posted 22 August 2010 - 12:26 PM

@PsichiX: thank you, that would also help me a lot. One more question though: does the EtSessionDownload() function take the the 'Transfer-Encoding' header field into account? (Transfer-encoding)

@IMP: I knew that, but it would be more easy to just use
EtSessionDownload(url, buffer);
and then be able to access the headers.
and for your question, i use it like this:
var title, descr, link;
title = EtXmlTagGet(xml, '?xml/rss/channel/title/');
descr = EtXmlTagGet(xml, '?xml/rss/channel/description/');
link = EtXmlTagGet(xml, '?xml/rss/channel/link/');
This is how I use it, so maybe you should also include the '?xml/' at the beginning?
I'll try test it out soon.

EDIT:
I got it to work:
str = '
<?xml version="1.0" encoding="UTF-8"?>
<statuses type="array">
<status>
  <created_at>Sat Aug 21 04:06:53 +0000 2010</created_at>
  <source>web</source>
  <truncated>false</truncated>
</status>
</statuses>
'

EtLibraryLoad('Ether.dll');

buffer = EtBufferCreate()
EtBufferWriteString(buffer, str);

xml = EtXmlCreate()
EtXmlParse(xml, buffer, chr(13) + chr(10) + chr(9) + ' ');

EtBufferFree(buffer);
EtBufferDestroy(buffer);

show_message(EtXmlTagGet(xml, '?xml/statuses/status/created_at/'));

EtXmlDestroy(xml);
EtLibraryFree();

Edited by kalzme, 22 August 2010 - 12:39 PM.

  • 0

#29 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Member
  • 9322 posts
  • Version:Unknown

Posted 22 August 2010 - 03:44 PM

@PsichiX: Correct me if I'm wrong (I don't know much about XML, to be honest), but aren't you supposed to only end a tag with /> if it's self-closing, i.e. has nothing inside it? In this case, the <statuses> tag has everything inside it :P .

@kalzme: Thank you! That worked! I never thought the parse was considering the <?xml?> tag as a tree tag :) . Thanks!

That said, now I'm a little confused. The <statuses> tag is an array of <status> tags. So how would I, for example, get the value of the created_at tag in the third (or fifth, or thirtieth) <status> tag?

*EDIT* Nevermind. I should look at the examples before asking questions, shouldn't I :P ? I've got it now, and it's working great!

-IMP ;) :)

Edited by IceMetalPunk, 22 August 2010 - 03:55 PM.

  • 0

#30 kalzme

kalzme

    GMC Member

  • GMC Member
  • 329 posts
  • Version:GM:Studio

Posted 22 August 2010 - 03:47 PM

@PsichiX: Correct me if I'm wrong (I don't know much about XML, to be honest), but aren't you supposed to only end a tag with /> if it's self-closing, i.e. has nothing inside it? In this case, the <statuses> tag has everything inside it :P .

@kalzme: Thank you! That worked! I never thought the parse was considering the <?xml?> tag as a tree tag :) . Thanks!

-IMP ;) :)

You are correct, I guess he didn't see the closing tag at the end.
I'm glad it worked.

Oh and by the way if the <statuses> tag has multiple <status> tags in it you can easily read them this way:
count = 0;
while(true) {
    var conf;
    conf = '?xml/statuses/status#id:' + string(count);
    if (EtXmlTagExists(xml, conf)) {
        EtXmlTagGet(xml, conf + '/created_at/');
        count += 1;
    }
    else {
        break;
    }
}

Edited by kalzme, 22 August 2010 - 03:51 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users