How to build my own cloud-data-server?
Moderator: MSandro
How to build my own cloud-data-server?
Hi, I want to create a small cloud based application but I don't want to put all the data on the official GP cloud-data-server, so I'd like to build my ow n cloud server for GP. I don't know what protocol or web service I heave to use for comunication between GP and my server. Is it a GP to GP connection or is GP sending the data to another server-side application?
Re: How to build my own cloud-data-server?
I'm having a look at this and I've got somewhere
(Running GP on a raspberry pi with modified CloudServer and MessageServer classes)
I can start a server on port 2002 on my Pi and connect to it from my Win10 but the Pi is not understanding the messages
But its a really good learning process :)
(Running GP on a raspberry pi with modified CloudServer and MessageServer classes)
I can start a server on port 2002 on my Pi and connect to it from my Win10 but the Pi is not understanding the messages
But its a really good learning process :)
Re: How to build my own cloud-data-server?
Yippee
I've got GP on Win10 sending message to my own server on a Raspberry Pi
I'll write it up tomorrow and then try and make it work simpler :)
I've got GP on Win10 sending message to my own server on a Raspberry Pi
I'll write it up tomorrow and then try and make it work simpler :)
Re: How to build my own cloud-data-server?
Ok , to start your own dataserver - you 1st need to create a folder called cloudServer on the computer you are going to use as the server
This folder needs to be in same folder as your GP installation
Then create folder within that called gp
Then import a class like this
and then run the block it creates
If you look in your console window - you should see a message that the server is listening on port 2002
Then to use it from another machine you can just edit CloudDataServer.gp in the GP lib folder and uncomment the 127.0.0.1 line and replace it with IP address of your server (I suggest leaving the digital ocean line alone in case you want to go back using it )
Simon
This folder needs to be in same folder as your GP installation
Then create folder within that called gp
Then import a class like this
Code: Select all
defineClass LocalDataServer morph
script 'LocalDataServer' 103 50 {
start (new 'CloudDataServer')
}
If you look in your console window - you should see a message that the server is listening on port 2002
Then to use it from another machine you can just edit CloudDataServer.gp in the GP lib folder and uncomment the 127.0.0.1 line and replace it with IP address of your server (I suggest leaving the digital ocean line alone in case you want to go back using it )
Simon
Re: How to build my own cloud-data-server?
Wow, thank you very much, it is much simpler than I thought.
Re: How to build my own cloud-data-server?
But what I do not understand is: why the CloudDataServer is not automaticaly creating new users if they don't exist. With the default setup we are limited to use only the "gp" user, also in the public cloud-data-server.
So I would suggest to change the file "CloudDataServer.gp" like this:
It doesn't work for me but I hope you know what I mean.
I heave changed the two if statements: "if (not (contains userNames user)) {" so it should add the new user to the list and create the folder.
So I would suggest to change the file "CloudDataServer.gp" like this:
Code: Select all
method handleGet CloudDataServer msg {
if ((count (args msg)) < 2) {
return (newRemoteMessage 'notEnoughArguments' (command msg))
}
user = (at (args msg) 1)
key = (at (args msg) 2)
if (not (and (isClass user 'String') (isClass key 'String'))) {
return (newRemoteMessage 'arguments must be strings')
}
user = (canonicalizedWord user)
if (not (contains userNames user)) {
userNames add user
makeDirectory (join './cloudServer/' (safeFileName this user)
// return (newRemoteMessage 'unknownUser' user)
}
data = (readFile (join './cloudServer/' (safeFileName this user) '/' (safeFileName this key)) true)
if (isNil data) {
return (newRemoteMessage 'fileNotFound' key)
}
response = (newRemoteMessage 'ok')
add (blobs response) data
return response
}
method handlePut CloudDataServer msg {
if (or ((count (args msg)) < 2) ((count (blobs msg)) < 1)) {
return (newRemoteMessage 'notEnoughArguments' (command msg))
}
user = (at (args msg) 1)
key = (at (args msg) 2)
if (not (and (isClass user 'String') (isClass key 'String'))) {
return (newRemoteMessage 'arguments must be strings')
}
user = (canonicalizedWord user)
if (not (contains userNames user)) {
userNames add user
makeDirectory (join './cloudServer/' (safeFileName this user)
// return (newRemoteMessage 'unknownUser' user)
}
data = (at (blobs msg) 1)
writeFile (join './cloudServer/' (safeFileName this user) '/' (safeFileName this key)) data
return (newRemoteMessage 'ok')
}
I heave changed the two if statements: "if (not (contains userNames user)) {" so it should add the new user to the list and create the folder.
Re: How to build my own cloud-data-server?
I think the CloudDataServer is just a very simple testbed and not intended for end use when beta ends
It just shows what can be achieved and lets people try out projects with things like high scores in games or simple turn based networked games
For full use it would need security and logins private/public access etc
It just shows what can be achieved and lets people try out projects with things like high scores in games or simple turn based networked games
For full use it would need security and logins private/public access etc
Re: How to build my own cloud-data-server?
Yes that seemst to be true, currently there are no security features like encryption and dectryption in GP to realize souch data-servers. GP currently only knows "sha256" and "hash" to create checksums for strings and binary data.
But now I've created my own expandable cloud-data-server for my GP projects. It is now able to automatically create new users (folders). And I use "sha256" for the folder (user) and file (key) names.
But now I've created my own expandable cloud-data-server for my GP projects. It is now able to automatically create new users (folders). And I use "sha256" for the folder (user) and file (key) names.