Jump to content




Wireless Peripheral API & Data Serialization API for LyqydNet

api peripheral networking

  • You cannot reply to this topic
No replies to this topic

#1 Timendainum

  • Members
  • 26 posts
  • LocationNether

Posted 30 November 2013 - 11:35 PM

I have developed a small set of scripts to enable wireless access of any computercraft peripherals. These scripts are mainly for my own use, but I thought others might be interested so I posted them.

Prerequisites
You must have an operational installation and functioning network using Lyqyd's LyqydNet API.
http://www.computerc...net-rednet-api/

Programs/APIs
  • nets - network serialization API

This API wraps up connection.send(), connection.awaitResponse() and connection.listenIdle() to allow full client/server serialization capability.


You will note that nets.send() allows multiple additional arguments. This allows the building of more complicated requests and responses. The api will also automatically return multiple results from functions calls from across the network.


http://pastebin.com/4tctWiT8


To Do: I need to wrap up the listen function for foreground servers. I haven't had a need for this yet, but I will get to it eventually.

  • nperi - network peripheral API

This API provides for a set of functions that mimic the peripheral API, except they all include an additional argument of server prior to the existing arguments.


This should work with any type of peripheral. I've tested quite a few but not all existing peripherals.


http://pastebin.com/APNEz5BY


To Do: I've been playing around with the connection management. In past versions I've opened and closed connections for every transaction, but that seemed wasteful. I've got a somewhat sloppy start to a connection pooling system going on now, but I'm not noticing any significant benefit in terms of network performance. More testing is definitely needed, consider this a work in progress.

  • nperid - network peripheral server daemon

For nperi to work you must be running a server on the computer that the peripheral is actually attached to. This is said server. It works as a background daemon and is started with a command like: shell.run("nperid")


http://pastebin.com/XhaDnyZ8


To Do: Connection management related to nperi is all I'm planning here. This seems to work pretty well so far.

  • test - nperi test program

This program contains a bunch of examples and tests for the system.


http://pastebin.com/auun2B4E



Other Resources
You can find more examples and my current working scripts here:
https://github.com/T...inum/Wintermute

Other Remarks
This is all a work in progress, so I am sure there are some rough parts. This is also my first Lua or ComputerCraft project so please be kind. That being said any constructive suggestions and feedback are welcomed.

Edited by Timendainum, 02 December 2013 - 06:33 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users