OSL ‐ Network - Mistium/Origin-OS GitHub Wiki

Info

Network commands let you interact with the internet, and the origin account server, the accounts system requires the "account" permission.

The originOS server allows you to log into your accounts and sync things like your profile picture, username, accent colour and a few other things over any originOS installation, on any computer.

You can also store your files in your origin account so you can log in and get back everything you had on any other computer.

All Networking Variables

You can access data about the current packet using the following variables:

new_network_data - a true or false of if there are new packets

packet.payload - the actual payload of data

packet.source - the source port of the message

packet.client - the client data from the user that sent the packet

{ // example for client var
  "system": "originOS",
  "version": "v5.0.7"
}

packet - the entire packet as a json object

Handling a packet

if new_network_data (
  log packet
  // log the full packet
  new_network_data = false
)

Using rotur commands

This app demonstrates the 2 rotur commands currently available in osl

"tester" is like a port, you can set a port to send your data to with rotur.

If you dont know what rotur is, find out about it here: https://github.com/RoturTW/main/wiki

"tester".roturConnect()
"Mist".roturSend("hello world","tester")
mainloop:
if new_network_data (
  log packet
  new_network_data = false
)
loc 2 2 10 -20
text packet 10 : c#fff
import "win-buttons"

Example Client Server

Server:

network "set_app_id" "Pinger"
total_pings = 0
mainloop:
if new_network_data (
  new_network_data = false
  if network_data == "ping" (
    // replies with the server timestamp
    network "send" ["ping"] + timestamp network_data_from
    total_pings ++
  )
)

loc 2 2 20 -20
c #fff
text total_pings 10

import "win-buttons"

Client:

network "set_app_id" "Pinger"

ping = "No Data"

mainloop:
if new_network_data (
  new_network_data = false
  if network_data.[1] == "ping" (
    // only runs if the source command is "ping"
    ping = network_data.[2]
  )
)
loc 2 2 20 -20
text ping 10 : c#fff

loc 2 2 20 -50
text "Press Space To Ping" 10

if "space".onpress (
  network "send" "ping" "server_name"
)
import "win-buttons"

Update

network "update" [key] [value]

You can set any key (doesn't have to be included below) to anything

Some keys are:

  • "pfp" (url to an image that is used as your profile picture)
  • "email" (It's your email)
  • "accent" (This is the accent colour that is linked to your account)

On success:

  • "Account Updated Successfully" (Your account has been updated with no issues)

Possible Errors:

  • "Not Logged In" (You aren't logged into an origin account)
  • "Update Value Must Be Less Than 500 Characters" (You tried to set a key to a value longer than 500 characters of text)
  • "Account Cannot Be Bigger Than 10kb" (You tried to upload a key to a value that would push your account's total size over 10kb)
  • "Unable to update: ["ips","last_login","max_size"]" (The key you tried to set is protected and not directly editable)

Get_Account_Username

network "find_account" [username]

On Success:

(Example received account object)

[
  {
    "username": "Mistium",
    "pfp": "https://cdn.discordapp.com/avatars/603952506330021898/6ae8c3eb990a3989be5cc92892336d33",
    "accent": "#57cdac"
  }
]

Errors:

  • "Account Not Found" - if the account doesn't exist you will get this message

My_Accounts

Returns a list of all accounts that have been logged in or created with your ip in the past

network "my_accounts"

On Success:

(Example received account object)

[
  {
    "username": "Mistium",
    "pfp": "https://cdn.discordapp.com/avatars/603952506330021898/6ae8c3eb990a3989be5cc92892336d33",
    "accent": "#57cdac",
    "last_login":"unicode timestamp of the last time this account was logged into"
  },
  {
    "username": "Mist2",
    "pfp": "https://cdn.discordapp.com/avatars/603952506330021898/6ae8c3eb990a3989be5cc92892336d33",
    "accent": "#57cdac",
    "last_login":"unicode timestamp of the last time this account was logged into"
  }
]

Or if you have no previous accounts you will be returned []

Myself

This command returns the data for the account you are currently logged into.

network "myself"

Possible Errors:

  • "Not Logged In" (You aren't logged into an origin account)

On Success:

(Example received account object)

{
  "username":"Mist",
  "password":"",
  "ips":[],
  "accent":"#57cdac","last_login":1703515687862,
  "max_size":"50000",
  "pfp":"https://cdn.discordapp.com/avatars/603952506330021898/6ae8c3eb990a3989be5cc92892336d33"
}

All your other keys (such as ones set through the update command) will be in this json too

Possible Errors:

  • "Not Logged In" (You aren't logged into an origin account)