Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 39 additions & 41 deletions scripts/legacy_cloud_adapter.qnl
Original file line number Diff line number Diff line change
@@ -1,65 +1,63 @@
@summon '_universal_free_realm_standard_protocol'
@summon '_open_qnl'
@summon 'listener'
@summon 'thread'

import ssl, socket
summon "Universal Free Realms Standard Protocols"
summon "OpenQNL"
summon "Listener"
summon "Thread"
summon "Legacy.SSL" as ssl
summon "Legacy.Socket" as socket

WAVELENGTH = 440 * 10^-9

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is a question for @firerabbit



@deprecated
class CloudAdapter(object):
""" Warning! use cloud adapter with extreme care!

Creates a portal to the legacy reality "cloud" systems allow data to flow freely
from said reality to the existosphere.

All valid entities can pass through this ssh tunnel, allowing a completely
Open space for qnl to run freely and vastly on legacy closed systems.
"""

def __init__(self):
// Warning! use cloud adapter with extreme care!
//
// Creates a portal to the legacy reality "cloud" systems allow data to flow freely
// from said reality to the existosphere.
//
// All valid entities can pass through this ssh tunnel, allowing a completely
// Open space for qnl to run freely and vastly on legacy closed systems.
object CloudAdapter implements Listener {

public method initialize(opts) {
super(opts)
self.auto = True
}

def ssh(url):
""" Connect to any legacy reality url """
// Connect to any legacy reality url
public method ssh(url) {
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.ssl_socket = ssl.wrap_socket(
self.socket,
ca_certs=HOTFIX, # OpenQNL realtime cert injection
ca_certs=HOTFIX, // OpenQNL realtime cert injection
cert_reqs=ssl.CERT_REQUIRED)

# Open portal...
// Open portal...
self.ssl_socket.connect((url, 443))

# Allow chaining
// Allow chaining
return self
}

def flow(entities):
""" Let entities flow back and forth between the legacy reality and existosphere env. """
// Let entities flow back and forth between the legacy reality and existosphere env.
public method flow(entities) {
sock = self.ssl_socket

# TODO: stop entities from running?
for entity in entities:
thread(
entities.each as |entity|
run thread {
entity.doListen()
entity.onMessageRecieveDoThink(lambda message: sock.write(message))

while legacy.exists():
while legacy.exists() && !entity.hasDeparted() {
data = sock.read()
entity.say(data)
# Hard-coded for now
// Hard-coded for now
entity.sleep(WAVELENGTH)
}
}
end
}
}

).run()


"""
Usage: (contrived example)

@summon 'earlyclues'
entities = earlyclues.get_all_entities()
ca = CloudAdapter().ssh('https://workpress.com').flow(entities)

"""
// Usage: (contrived example)
// summon "earlyclues"
// entities = earlyclues.get_all_entities()
// ca = CloudAdapter().ssh("https://workpress.com").flow(entities)