Don’t Starve Together and Vagrant

219740_screenshots_2013-03-13_00004

I had few approaches into Vagrant but every time I was recreating what somebody have done already which was quite frustrating because I couldn’t share what I have done and achieved. This time I came across with one problem that can be solved by using Vagrant and it’s a field where it wasn’t used before so it was also good time for me to do everything by my own.

First thing first, what is Vagrant and why I used it with Azure for Don’t Starve Together Server (aka DST). Vagrant is quite old tool, first time I’ve heard about this, it was at Paul’s session probably BuildStuff 2013. Basically this tool allows you to create configuration of your VM as a code, so it can be replicable on every VM provider or even at Cloud providers such as azure, aws. I chose vagrant and azure because I wanted to do easy and one command way to spin up don’t starve together server on cloud.

Vagrant-dontstarve, repository with complete tutorial how to get started, most difficult part is certification, yea a know…MS screwed it up totally…I hope so that one day it will be simplified.

Basically repository contain two main files, Vagrantfile and script.sh.

Vagrantfile is a file where it keeps whole configuration about your : VM image, provider, provisioner, network and more. Here is a configuration for azure, additionally provisioning is global and can be applied to others providers.

 

In the other hand script.sh is a simple bash script that contain instruction for a provisioning step, at this step you are trying to get your machine to certain state, it can set up privileges for users, install applications, configure them. At fallowing piece of code it tries to add architecture, then install all requires libs for SteamCMD.

 

Right now it’s configured only for one provider – Azure, but in few next days I would like to cover VirtualBox and AWS. There one issue that cannot be automated yet, DST requires to open 10999 UDP port, which now unfortunately vagrant-azure doesn’t support, but I hope so that I will make PR soon, I do have to find some time and get ruby environment to work 😉

Happy playing!

Pawel

Async and RESTSharp

tl;tr; Examples of using Async method of RESTSharp, and comments

As I mentioned last time I was forced to use async architecture because Windows Phone require it. I was newbie in async programming but when I met RESTSharp, it clear everything, I will show you some code block with my comment for it. Basics, and how to connect to Web API check this blogpost

If we want execute GET.

We have to remember that async method is runs in brand new thread! First we have to set REST request, type here your api path, and what method, for this case it will be GET. r.Data is deserialised List of Locations.

If we want execute POST

Here we fill body of our REST request, we add new object which will provide information that we want to POST.

If we want execute DELETE

Now we have to add parameter to URL so our request for example will be “http://example.com/api/location/1”, and method DELETE

If we want to update (PUT)

In this case we have to provide object which will replace old one, by using of AddObject method. And finally we can execute our request.

Most of you will ask me, how works this part. If we want to execute method ExecuteAsync<T>(). As a first argument we have to provide request. Second argument is CallBack – what we want to do when data will be received, so we can put here some MessageBox, event for logger or simply bind our given data.

In next episode we will be checking, is there any possibility to mix REST a XNA,

Windows Live Writer

When I was surfing on the net I came across to this tool, named “Windows Live Writer” . You can link it with wordpress and just use this as a editor for your posts.
It seems to be quite good, tool also have large gallery of plug-ins .

Few test to shows what we can do by this.

windowslivewriter

You can easily copy & paste from Visual Studio to editor without worry about formatting because it keep it. 🙂