PDA

View Full Version : Impressed and amazed



LarsSiden
2007-01-05, 15:31
Hello,

As a senior developer and System Architect working on the .Net platform these days, I really must say that I am impressed of what you have accomplished! My hat is off for you guys!

I worked with Perl long ago - using Sybase WebHtml/perl 1996, never really liked it :-)

Is there any documents on "how to develop for Slimserver" somewhere? I guees that I somehow can interact using C# somehow... don't know what to do - yet!

Are there documents describing the architecture? ie what is happening in the client(SB) and in the server? For instance I'd be intersted in having the server language in English but the client in Swedish.

But most important - GOOD WORK! Keep it up!

Best regards,

Lars Siden

Sweden

stinkingpig
2007-01-05, 16:40
On 1/5/07, LarsSiden
<LarsSiden.2jyl4b1168036502 (AT) no-mx (DOT) forums.slimdevices.com> wrote:
>
> Hello,
>
> As a senior developer and System Architect working on the .Net platform
> these days, I really must say that I am impressed of what you have
> accomplished! My hat is off for you guys!
>
> I worked with Perl long ago - using Sybase WebHtml/perl 1996, never
> really liked it :-)
>
> Is there any documents on "how to develop for Slimserver" somewhere? I
> guees that I somehow can interact using C# somehow... don't know what
> to do - yet!
>
> Are there documents describing the architecture? ie what is happening
> in the client(SB) and in the server? For instance I'd be intersted in
> having the server language in English but the client in Swedish.
>
> But most important - GOOD WORK! Keep it up!
>

http://wiki.slimdevices.com/index.cgi?DeveloperGuide

But if you want to work in something else, you're best off with the
command line interface. http://YOUR_SERVER:9000/html/docs/cli-api.html
--
"I spent all me tin with the ladies drinking gin,
So across the Western ocean I must wander" -- traditional

GoCubs
2007-01-05, 17:20
There's also a bunch of info available from the SlimServer web interface under Help -> Technical Information.

Before I wrote my first plugin I used this info as well as just browsing the code for some of the existing plugins...

-Greg

LarsSiden
2007-01-06, 14:51
Hi guys,

Started a simple c# .Net project this evening after checking a perl-script for displaying caller id.

Based on the perl code I did this:

1. Connected to my Slimserver on port 9000
2. Sent a command followed by newline
3. Listened for response

it didn't work :-)
All I get is "405 Method Not Allowed:"

If this becuse I'm running a standalone appliction and not as a plugin? have I totally misunderstood everything!

I haven't found any list with valid commands to send to the server?

Do I to connect to the server to send messages to my SB? Or do I connect to the SB directly?

As the title says, kick me gently in the right direction!

// Lazze

-------- Code snippets -----

public void ConnectToSlimServer ( string hostName, int Port )
{
try
{
IPAddress[] IPs = Dns.GetHostAddresses(hostName);

workingSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);


workingSocket.Connect(IPs[0], Port);
tbStatus.AppendText(string.Format("Connected to: {0}", hostName));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,"Connect Error");
}
}


public void SendCmdToSlimServer(string cmdText)
{
try
{
ConnectToSlimServer("filuren", 9000);
tbStatus.Clear();
byte[] bCmd2Send = ConvertStringToByteArray(cmdText+"\r\n");
workingSocket.Send(bCmd2Send);

int bytes = 0;
string page = "";
Byte[] bytesReceived = new Byte[256];

// The following will block until te page is transmitted.
do
{
bytes = workingSocket.Receive(bytesReceived, bytesReceived.Length, 0);
page = page + Encoding.ASCII.GetString(bytesReceived, 0, bytes);
}
while (bytes > 0);

tbStatus.AppendText(page);
DisconnectToSlimServer();
}
catch (Exception ex)
{

MessageBox.Show(ex.Message,"Send Command Error");
}
}

kdf
2007-01-06, 15:14
On 6-Jan-07, at 1:51 PM, LarsSiden wrote:

>
> Hi guys,
>
> Started a simple c# .Net project this evening after checking a
> perl-script for displaying caller id.
>
> Based on the perl code I did this:
>
> 1. Connected to my Slimserver on port 9000
> 2. Sent a command followed by newline
> 3. Listened for response
>
if you are attempting to contact the server using the CLI, you must use
port 9090. port 9000 is for the web access.

for a list of commands, look at the Help section, under Technical
Information. There is an item called Command Line Interface that
covers it very well.
-kdf

LarsSiden
2007-01-07, 06:40
Thanks for the help guys! Now I'm close...

Int32 bytes = stream.Read(data, 0, data.Length);

responseData = System.Web.HttpUtility.UrlDecode(data, Encoding.Unicode);

In the docs it says "urlencoded UTF8" as format. As far as I can see it is UTF8 saved in 16bit Unicode.

So when I issue the command "player count ?", I get the following reply

"player+count+%3f" (this is after Urldecode and Unicode conversion)

Almost correct :-) I don't know what the + does and why I don't get "1" in the end. %3f == ?

If I use windows Telnet the result is correct.

Any ideas?

//Lz

LarsSiden
2007-01-07, 13:58
Got it working now!

I found an open source telnet client for .NET which I modified to suite my needs. Obviously Slimserver uses some control characters/sequences that I wasn't aware of, but now when I'm using this telnetWrapper class it all works like a charm.

If there are any interest maybe I could make like a "hello world" from C# .NET that could be published among the other samples.

//Lazze

Fred
2007-01-07, 15:58
In the docs it says "urlencoded UTF8" as format. As far as I can see it is UTF8 saved in 16bit Unicode.

What's in the IP packet is utf8, url encoded (percent-escaped) as per RFC 1738. Check <http://en.wikipedia.org/wiki/Percent-encoding> for pointers.


"player+count+%3f" (this is after Urldecode and Unicode conversion)

The "+" may be trying to represent a space. If you check the URL above, you'll see this how spaces are supposed to be encoded in HTML FORMS (not urls). Some libraries around still don't make the difference for some reason.

I am guessing "player+count+%3f" is what you send the CLI and what it returned verbatim since it did not understand it. Enabling the CLI debug log (in Server Preferences -> Debugging) and checking the log could help confirm this.


Obviously Slimserver uses some control characters/sequences that I wasn't aware of.

I am afraid it is more likely you're not aware of what exactly happens in .NET :)

Anyway it all works for you know so let us know if you have question on the CLI or Slimserver!

Fred

inguz
2007-01-08, 06:29
I have some (not very sophisticated yet) CLI wrappers in C#, happy to share them - just send me email.

LarsSiden
2007-01-08, 14:57
Inguz, you have disabled your email for this board.

I'dl like to have a look at your code, I have checked the server log now and I can see that my code "disconnects" after sendning the command, don't know why. Works when I go through the telnet wrapper.

Have you made a perl-plugin startup page? To activate your code from the player menus?

my mail adress: larssiden@gmail.com

// Lazze

LarsSiden
2007-01-11, 04:24
The reason that the commande I sent wasn't executed was a simple(once found :-)

I had reversed the order of \n\r 0A 0D

//LZ

Fred
2007-01-11, 17:11
You mean in your first home made attempt? That should work, normally. I'll have a look.

Fred