Thursday, September 11, 2008

Generic Serialize/Deserialize

Ok I'm playing with some Silverlight and with WCF. And while if you stick with the standard stuff it works great, but if you want something special you get trouble. And I wanted DUPLEX communication. Ok more on that in a later blog. Smile

Here is some cool code I used to Serialize/Deserialize some off the communication I'm doing between Silverlight and WCF.

private T Read<T>(string value)
XmlSerializer serializer = new XmlSerializer(typeof(T));
return (T) serializer.Deserialize(new StringReader(value));

private string Write<T>(T value)
StringWriter writer = new StringWriter();
XmlSerializer serializer = new XmlSerializer(typeof(T));
serializer.Serialize(writer, value);
return writer.ToString();

It uses generics, introduced in .NET Framework 2.0. Let me know if you can use it.

Tuesday, July 29, 2008

The new short me :)

Sometimes you wanna do funny things, or dress funny. Well lucky for me there are Loco Pocos. This funny tinys are almost completely made of sculptys and with the hud you can do funny things. 

Friday, July 25, 2008

Another day, another story

With software development there is always something, something that works great and something that doesn't work. Today was not different from that.

So today I worked again on the WCF service to connect any client to SecondLife®. First up was to get a simple local chat going, receiving that chat from SL and sending chat to SL. From looking at the test client within libsecondlife that was pretty easy to implement. Its for me also the first time I build from scratch a service that uses libsecondlife.

Second up was the friendslist. Probalby the most important feature of SecondLIfe :). A first problem popped up. When right after login want to read you're friendslist, it knows the amount off friends but doesn't know there names. Pretty annoying because automatic getting the friendslist from WCF service is pretty much out of the question, or I need to find a sleep function. So the first extention of the service was born, to receive the friendslist you send a message to the service. After that the service send you all the details of your friends. If it is a long list it will probably take some time. Have to test that.

Last job of the day was getting away from my simple command program to test the WCF service. So delving right into it, I thought about building a silverlight client. So there I bumped into a big problem. When connecting to the service it default enables (and cant be disabled) that the service is async. That has a major effect. I think because it is a "wsDualHttpBinding", and if so that major sucks. :(

Ok I'm off to bed :) Tomorrow another day, another story....

Wednesday, July 23, 2008

WCF services for LibSecondlife/Second Life®

Ok lets talk a little about the service I'm building. As this is my first time building a WCF service, so I have kept it simple. Looking at it right now the front-end service has 6 methods. All are defined as one way. Still de service is setup as "wsDualHttpBinding", for that there is a second interface, this one doesn't has a front-end page. So a little code: (also a little test on how this looks)

[ServiceContract(CallbackContract = typeof(ISecondService))]
public interface IRegisterService
[OperationContract(IsOneWay = true)]
void RegisterClient(Guid clientID);

[OperationContract(IsOneWay = true)]
void LoginUser(Guid clientID, LoginData loginData);

[OperationContract(IsOneWay = true)]
void LogoutUser(Guid clientID);

[OperationContract(IsOneWay = true)]
void RecieveMessage(Guid clientID, RecieveMessageBase recieveMessage);

This is the main interface. First you register your client with the service. The two other methods are to login/logout of Second Life. The last method is the method used to send a message from your client to the service (the service receives a message).

Now the nice thing about WCF is that you can have "DualHttpBinding", meaning the service can send message to the client. So when Second Life is sending a message to the client, this is first picked up by the WCF service and then send to the client. First of I was thinking of making a polling application, but this is way cleaner. It has his setbacks but more on that on another post. The interface code for the return message looks like this:

public interface ISecondService
[OperationContract(IsOneWay = true)]
void CheckAliveClient();

[OperationContract(IsOneWay = true)]
void SendMessage(SendMessageBase message);

The first method is a way to check if the client is still alive. The second is to send a message to the client. Its that simple. :)

Ok more on it soon, now trying to build in Chat.

A New Toy/Gadget

Well finally got my new toy, a HTC Touch Diamond, no not a iPhone 3G, but a pretty light phone with a iPhone type of interface.

The first task was actually not exploring the new toy but getting it to a English rom. Luckily for me there is a great web-site called: XDA-developers. A specially the forum has a great section about installing custom roms. So now I don't have a Dutch HTC but a English HTC.

The beauty of the HTC Diamond is its interface, the TouchFlo 3D. Controlling many applications with the touch of your fingers. I like it a lot. I also have a QTek S200, that one has Windows Mobile 5. The HTC has Windows Mobile 6.1, but compare to the QTek you dont see much of the Windows Mobile and that is good. This need to find a good Calendar program. The one inside Windows Mobile works but doesn't work very good.

PS  To get from a Dutch HTC to a English HTC, first Hard SPL your device, and then apply the new rom, in my case Elite 2.0.

Tuesday, July 22, 2008

Starting work on SecondViewer

I have taken it up on me to write a simple Second Life™ viewer with WCF and Silverlight/WPF. Now that on it self is not a very simple task. There are a few challenges. First there is the communication with the Second Life servers. This is made easy with LibSecondlife, a full Library to communicate with the Second Life servers. Second there is the fact that this all has to run in IIS. Meaning that inside IIS we have to keep a connection alive to the Second Life™ servers.

Hopefully I can keep you informed about my progress on this little blog.

Monday, July 21, 2008

The normal title: First post :)

OK first post, what to tell here, what not to tell here.
This is just me babbling about work (programming), free time and all second life related. My interest, my adventures and maybe more, who knows what.

Also I'm just looking around and see how this here works. See if I like it. :) Maybe start my own blog on my own website. More ltr.