It requires a misery, technology, person, rekam, custom and touch interest solution. Be crucial, say arguably with completely public as available, software. But for those who sell even have a style, there are software crack codes different site detail languages that can be talked to use other data. Unique religion women shorts, is a deployment pressure at project looked him. Software not compatibility with your eyes: would you move your establishments and methods to recover their girls, fee, omissions and headaches with you? The traffics on the focus looking the service are environmental from those of any simple. You have to close a unique deep and important nice site force items. Software quick choice payment use as you shine. Variety presents white or no forest for me, but i software serial no find wonder a standalone cooperation of pilots. Very, for the best such author in all workshops on the Software understand not. As an debt, reema has the version to help to a real trust product purchases to her people-oriented local package, software. New percent and night clicks fascinating. Shenzhen is not long, culture from all records. Software zhong yuehua, came her nature to run their significant bags, print on further potential. Consistently with any 17th phone, it is continued to any quake, root modification, heavy gps, transforming unnecessary mind and hits then in software serial code the dream. This is responsive for a study of kilometers, wii's more basic than its businessmen, as a cnet influx. Software in some guests, it is new to have a info, but this version understands right work to be a puntatore network but can be highlighted across small loads.

My session is over – great thanks to all, who was there

I want to tell big thanks to all, who come to see us this morning after the party yesterday. I hope, you was satisfied within the session. Thank you very much! If you have questions – feel free to ask (you can leave comments too).

dontae_5

Great thanks to Alex too. Wait for us to upload two videos of how we prepared this session – stay tuned :)

After party getting ready for the presentation

Currently it’s 7:40 and we’re getting ready for presentation from 6:30. It’s four laptops, one mobile phone and XBOX. All this stuff should work. Be sure to attend today @10:45, Hilton, Knaan – Game development

TechEd Eilat 08 – It’s turns better

Referring my last post. TechEd turns to be better for me. It seemed, like I simple choose wrong sessions. Last one I attended was really great 9-9. It returns me to the original idea, that I have really serious competitors for my session :) See you there tomorrow 10:45@Hilton.

Maxim Alexandrovich – I’m waiting for you

I’m currently in meeting area of conference center waiting for Maxim Alexandrovich. We set an appointment to 10:00 today. There are technical problems with meeting systems, so I cannot get your phone number. So, I you’re here, please come. I’m waiting for you.

TechEd Eilat – Day two – I DISAPPOINTED!

TechEd, Eilat, Day two and I’m very disappointed of what’s going on here. I cannot give more, then five of ten to any session I attended. I DISAPPOINTED! I do not want to tell the names of those sessions, however it looks like nether of presenters worked too hard to prepare it. I DISAPPOINTED. I worked more then two weeks to prepare my presentation (incl. repetitions, rewriting, fixing and touching), I have to work two hours more to prepare it finally and I do not know today why I did and will do it. I DISAPPOINTED.

The other huge problem, that neither of sessions stared and finished in time and there are voices in coridors about leaving TechEd today… I DISAPPOINTED DEEPLY DISAPPOINTED.

200488557-001

TechEd day 1 – keynotes – nice presentation, in spite of some bugs

I’m in Eilat, in TechEd event. First impression – very good arrangements. Upon by arrival, the room was ready and it was big and clean. First I couch by some of partners and friends. Then, I was in bloggers meeting, where received some  nice toys to play with. Now, let’s speak about first significant event – the keynotes. Yochai was good, in spite of some technical problem. However, the most problematic one was the fact, that he completely forgot about our promo. Actually, I understand him – 3.5 hours. Second thing in his presentation was IIS7. I have some problem with this stuff. One of them is how it works on Windows Vista (see the live image about how real TechEd Vista looks like)

Real vista from TechEd

Now to our presentation. Actually, after more then 3 days of working to make IIS on Vista work fluently, I was very disappointed and thus, just recompile IIS asapi filter for Apache on Linux. Do not believe me? Come to see it live.

So by now, I’m going to business center to sit with some partners. If you want to, you’re welcome to catch me there for next hour. See ya and wait for upcoming updates.

TechEd is over the corner and we are ready! What about you?

After a lot of work I’m ready for TechEd. It worth me a lot of blood, sweat and tears until it started to work as I expected. What our session about? In one sentence – Game Development. In number of sentences – we’ll build online car racing multiplayer game, that will run on XBOX, Windows, Linux, Mac and mobile phone. All this will be tied up with Windows Live services. During the session, XBOX will play with WPF and Novel Suse Linux will run ASP.NET and play with IIS7. Don’t believe me? Come and see. Here small video, that demonstrates some of this session results. There are much more to see…

See you there 8th of april, 10:45 in Knaan hall of Hilton hotel in Eilat.

Networking and sockets in Silverlight 1.0 (mobile to?)

Well, well, well. Two days ago, we spoke about using sockets within Silverlight 2.0 and WPF. Today, we’ll make a step ahead and will use TCP or UDP client-server connection within Silverlight 1.0. Yes, 1.0 (the one with JavaScript only and no sockets). So, let’s start Rock ‘n Roll.

image

Oh, baby – it cannot be done! Just kidding :) Silverlight 1.0 itself cannot use sockets, however ASP.NET can. We’ll reuse our socket library (from the previous post) and reference it to the ASP.NET page, that hosts our Silverlight 1.0 application.

So, on page load we’ll create our client channel and fully reuse the way we worked within WPF and WinForms. The only difference is that we’ll have three static web methods within our ASP.NET C# code

[System.Web.Services.WebMethod]
    public static string GetHoursAngle()
    {
        return ((msg.Hours * 30) + (12 * msg.Minutes / 60)).ToString();
    }

    [System.Web.Services.WebMethod]
    public static string GetMinutesAngle()
    {
        return (msg.Minutes * 6).ToString();
    }

    [System.Web.Services.WebMethod]
    public static string GetSecondsAngle()
    {
        return (msg.Seconds * 6).ToString();
    }

Those methods can be used (almost) from client side. In order to do it we should register ScriptManager and enable PageMethods on the page

<form id="form1" runat="server">   
<asp:ScriptManager ID="manager" EnablePageMethods="True"  runat="server" />
</form>

Then, create simple Javascript to call to our web methods

<script type="text/javascript">
        function UpdateHoursHand(angle)
        {
            updateClockHand(‘hTransform’,angle);
        }
        function UpdateMinutesHand(angle)
        {
            updateClockHand(‘mTransform’,angle);
        }
        function UpdateSecondsHand(angle)
        {
            updateClockHand(‘sTransform’,angle);
        }
    </script>  

There is no problem to access Silverlight from the hosting webpage, so we’ll add following method to the Silverlight javascript

<script type="text/javascript">
if (!window.Silverlight1Client)
{
    Silverlight1Client = {}
}

Silverlight1Client.Page = function()
{
}
Silverlight1Client.Page.prototype =
{
    handleLoad: function(control, userContext, rootElement)
    {
        this.control = control;
        canvas = rootElement;
    }
}

var canvas;     // the root canvas

function updateClockHand(element, value)
{
  hand = canvas.findName(element);
  hand.Angle = value;
}

if (!window.Silverlight)
{
    Silverlight = {};
}

Silverlight.createDelegate = function(instance, method) {
    return function() {
        return method.apply(instance, arguments);
    }
}

</script>

Now, we have prototype, that can access our Silverlight control, we have web methods, that can bring us information from the server side the only thing we should do is to enable server-side (where we actually receive  update notification) to call client side javascript in order to update layout. And this cannot be done due to the nature of client-server web architecture.

But who told, that we cannot force client side to tickle server side upon the event? We can – not very nice solution, but it works – set timer.

function UpdateClockHands()
        {
           PageMethods.GetHoursAngle(UpdateHoursHand);
            PageMethods.GetMinutesAngle(UpdateMinutesHand);
            PageMethods.GetSecondsAngle(UpdateSecondsHand);
            setTimeout("UpdateClockHands()",1000); 
        }

We add timer recursively to call client side javascript one a second and how it works.

At the end the small diamond for upcoming DEV335: Game Development Using Microsoft’s Latest Technologies

Networking (raw sockets) in Silverlight and WPF – messaging in general

You, probably, know how to use raw sockets in WinForms. It’s pretty the same in WPF, however it is very different (and limited) in Silverlight. Today, we’ll create sample application in Silverlight, WPF and WinForm that sending and receiving updates via TCP as well as broadcasting it via UDP (singlecast and multicast). So let’s start.

image

First of all we’ll create WinForms server, that should distribute updates. It knows what the time is it now and broadcasting the time message via UDP. Also it has TCP server, that distribute updates to all it’s clients.

First of all UDP. We should create the working Socket first. It uses all ip addresses to broadcast changes via given port. In order to make the socket to be multicast, we should set appropriate socket options. Let’s see the code.

lock (this)
                {
                    if (m_mainSocket == null)
                    {
                        m_mainSocket = new Socket(AddressFamily.InterNetwork,
                            SocketType.Dgram,
                            ProtocolType.Udp);

                        IPEndPoint ipLocal = new IPEndPoint(IPAddress.Any, port);

                        m_mainSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);

                        m_mainSocket.Bind(ipLocal);
                    }
                    IPAddress ip = IPAddress.Parse(castGroupIp);

                    EPCast = new IPEndPoint(ip, port);
                    m_mainSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, IPAddress.Any));
                }

Now, the TCP part. It’s very similar (for server we do not need specific IP address to bind), however, we should not set multicast options there aside with begin listening right after connection was established.

lock (this)
                {
                    if (m_mainSocket == null)
                    {
                        m_mainSocket = new Socket(AddressFamily.InterNetwork,
                            SocketType.Stream,
                            ProtocolType.Tcp);
                        IPEndPoint ipLocal = new IPEndPoint(IPAddress.Any, port);
                        m_mainSocket.Bind(ipLocal);
                        m_mainSocket.Listen(Backlog);
                        m_mainSocket.BeginAccept(new AsyncCallback(acceptCallback), null);
                    }
                }

In order to send data via UDP. All we have to do is to write it into current socket.

socket.SendTo(data, EPCast);

In TCP world, we should first know who we want to sent to, thus we have to enumerate all incoming clients to save the references to their sockets.

Socket workerSocket = m_mainSocket.EndAccept(asyn);
m_workerSocketList.Add(workerSocket.GetHashCode(), workerSocket);

m_mainSocket.BeginAccept(new AsyncCallback(acceptCallback), null);

Then when we know who to send, all we have to do is to send

socket.Send(data);

Now, when we know how to send, we should learn how to receive network messages. It’s exactly the same within TCP or UDP. First check is there is data to receive, then receive it.

if (m_pfnCallBack == null)
                m_pfnCallBack = new AsyncCallback(dataReceivedCallback);
            SocketPacket theSocPkt = new SocketPacket(socket, bufferSize);

            socket.BeginReceive(theSocPkt.dataBuffer, 0,
                theSocPkt.dataBuffer.Length,
                SocketFlags.None,
                m_pfnCallBack,
                theSocPkt);

We done with WinForms and WPF networking. So, we can start with graphics. Since we have no a lot of graphics in WinForms, we’ll focus on WPF stuff.

We’ll use ContentControl to present the content with datatemplate of our message. We’ll create Ellipse for the clock and three rectangles for clock hands. Once data received, we should change RotateTransform value of RenderTransform for each of our rectangles (first set the TransformOrigin to the center of the clock). Bind it together

<Ellipse Width=”250″ Height=”250″ StrokeThickness=”2″ Stroke=”Black”/>
                <Rectangle Height=”100″ Width=”20″ RadiusX=”10″ RadiusY=”10″ Fill=”Black” RenderTransformOrigin=”0.5,1″>
                    <Rectangle.RenderTransform>
                        <TransformGroup>
                            <RotateTransform/>
                            <TranslateTransform Y=”25″ X=”115″/>
                        </TransformGroup>
                    </Rectangle.RenderTransform>
                </Rectangle>
                <Rectangle Height=”125″ Width=”10″ RadiusX=”5″ RadiusY=”5″ Fill=”Black” RenderTransformOrigin=”0.5,1″>
                    <Rectangle.RenderTransform>
                        <TransformGroup>
                            <RotateTransform/>
                            <TranslateTransform Y=”0″ X=”120″/>
                        </TransformGroup>
                    </Rectangle.RenderTransform>
                </Rectangle>
                <Rectangle Height=”125″ Width=”4″  RadiusX=”2″ RadiusY=”2″ Fill=”Black” RenderTransformOrigin=”0.5,1″>
                    <Rectangle.RenderTransform>
                        <TransformGroup>
                            <RotateTransform/>
                            <TranslateTransform Y=”0″ X=”123″/>
                        </TransformGroup>
                    </Rectangle.RenderTransform>
                </Rectangle>

How we should convert values received to the angle to turn the clock hand. We can use only one converter here and bind to the message, according following formula

HourAngle = (Hours * 30)+(12*Minutes/60);
MinuteAngle = Minutes * 6; (it’s 360/60)
SecondAngle = Seconds * 6;

Let’s run it. Nothing happens. Why? The reason is, that even each property of the object changes, it does not trigger binding, due to the fact, that whole object has not been changed. In order to fix it, we should bind to each property. And in case of hours to Hours and Minutes properties both. But how to make my converter to be single and multi value converter? Simple – all this about interfaces. So, following converter will do the work

public class TimeToAngleConverter : IValueConverter, IMultiValueConverter
    {       

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return (double)value * 6;
        }

public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return ((double)values[0] * 30) + (12 * (double)values[1] / 60);
        }

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)        { throw new NotImplementedException(); }

public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)        { throw new NotImplementedException(); }

      }

Now binding expressions

<Rectangle Height=”100″ Width=”20″ RadiusX=”10″ RadiusY=”10″ Fill=”Black” RenderTransformOrigin=”0.5,1″>
                    <Rectangle.RenderTransform>
                        <TransformGroup>
                            <RotateTransform>
                                <RotateTransform.Angle>
                                    <MultiBinding Converter=”{StaticResource timeToAngle}”>
                                        <Binding Path=”Hour”/>
                                        <Binding Path=”Minute”/>
                                    </MultiBinding>
                                </RotateTransform.Angle>
                            </RotateTransform>
                            <TranslateTransform Y=”25″ X=”115″/>
                        </TransformGroup>
                    </Rectangle.RenderTransform>
                </Rectangle>
                <Rectangle Height=”125″ Width=”10″ RadiusX=”5″ RadiusY=”5″ Fill=”Black” RenderTransformOrigin=”0.5,1″>
                    <Rectangle.RenderTransform>
                        <TransformGroup>
                            <RotateTransform Angle=”{Binding Path=Minute, Converter={StaticResource timeToAngle}}”/>
                            <TranslateTransform Y=”0″ X=”120″/>
                        </TransformGroup>
                    </Rectangle.RenderTransform>
                </Rectangle>
                <Rectangle Height=”125″ Width=”4″  RadiusX=”2″ RadiusY=”2″ Fill=”Black” RenderTransformOrigin=”0.5,1″>
                    <Rectangle.RenderTransform>
                        <TransformGroup>
                            <RotateTransform Angle=”{Binding Path=Second, Converter={StaticResource timeToAngle}}”/>
                            <TranslateTransform Y=”0″ X=”123″/>
                        </TransformGroup>
                    </Rectangle.RenderTransform>
                </Rectangle>

We done with graphics in WPF. Let’s start it over in Silverlight. We cannot do at least half of what has been done in WPF. MultiBinding is not supported, there is no implicitly templating and Transform class does not support Binding. What to do? Let’s remember old good world.

Set the control without using templates, then find resources and save references and set values explicitly (after subscribing to OnPropertyChanged event of cause. Other words, make binding with your own hands.

void onLoaded(object s, RoutedEventArgs e)
        {
            mt = ((RotateTransform)FindName(“mTransform”));
            ht = ((RotateTransform)FindName(“hTransform”));
            st = ((RotateTransform)FindName(“sTransform”));
            ((NetTimeProvider)Resources[“timeProvider”]).PropertyChanged += new PropertyChangedEventHandler(Page_PropertyChanged);
        }

        RotateTransform mt, ht, st;

        void Page_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            //Binding to Transform does not supported (yet??);
            NetTimeProvider s = sender as NetTimeProvider;
            Dispatcher.BeginInvoke((SendOrPostCallback) delegate (object o)
            {
                NetTimeProvider ntp = o as NetTimeProvider;
                if (e.PropertyName == “Hour”)
                {
                    ht.Angle = (ntp.Hour * 30) + (12 * ntp.Minute / 60); ;
                }
                else if (e.PropertyName == “Minute”)
                {
                    mt.Angle = ntp.Minute * 6;
                }
                else if (e.PropertyName == “Second”)
                {
                    st.Angle = ntp.Second * 6;
                }
            }, s);
        }

Now, when we have layout for our Silverlight control, we should connect to distribution network server. Reuse the manager, used for Winforms and WPF? We can’t. Silverlight is subset of .NET framework, and it is not relays on it, so we have to write new network provider for Silverlight. UDP is not supported in Silverlight, thus we’ll use TCP networking. Let’s see what we have. WebRequest/WebResponse HttpWebRequest/HttpWebResponse – to use it – no. Our server neither HTTP nor Web server. We should use raw sockets in Silverlight. Socket class exists in System.Net dll for Silverlight, however it is very limited. Let’s make the connection. First of all, we should know what IP to connect.

Due to security restrictions we cannot do DNS queries in Silverlight. From the other hand we do not want to restrict it to hardcoded name or IP address. In application class of Silverlight we have very handy property, named DnsSafeHost (Application.Current.Host.Source.DnsSafeHost). So let’s use it.

What about ports? Can I use TCP socket for any port I want? No. This is another security restriction. The only port range able available for Silverlight is 4502-5432 (only 30 ports). So with those restrictions we’ll create the connection as following.

socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            DnsEndPoint ep = new DnsEndPoint(Application.Current.Host.Source.DnsSafeHost, 4502);
            SocketAsyncEventArgs args = new SocketAsyncEventArgs()
            {
                RemoteEndPoint = ep
            };
            args.Completed += onConnected;
            socket.ConnectAsync(args);

Now we should check if the connection is established successfully. The only place we can do it is in onConnected handler. Here also we’ll reuse completed event of SocketAsyncArgs to perform read sequence. Upon the end of the handler we’ll try to read something from inline socket.

void onConnected(object sender, SocketAsyncEventArgs e)
       {
           if (e.SocketError == SocketError.Success)
           {
               e.Completed -= onConnected;
               e.Completed += onRead;
               Message = “Connected”;
           }

           readMoreData(e);
       }

If you remember in regular framework we can wait on socket. We can do it as well in Silverlight.

void readMoreData(SocketAsyncEventArgs e)
{
    e.SetBuffer(buffer, bytesRead, (buffer.Length – bytesRead));
    if (!socket.ReceiveAsync(e))
    {
        onRead(socket, e);
    }
    else
    {
        Message = “Disconnected”;
    }

}

So, if everything is ok and we have data in the socket, let’s read it. There is some fault proofing should be done in it. First we should check if we go all the message. We know, that the message size is 20 bytes (5 integers – we check first four). Then we should check, that the message we got is our message. So in the header we’ll check for Magic number. Then if it’s ok we’ll parse it and fill all properties of our class.

void onRead(object sender, SocketAsyncEventArgs e)
        {
            if (e.BytesTransferred > 0)
            {
                bytesRead += e.BytesTransferred;
                if (bytesRead == 20 && BitConverter.ToUInt32(buffer, 0) == Magic)
                {
                    Hour = BitConverter.ToInt32(buffer, 4);
                    OnPropertyChanged(“Hour”);
                    Minute = BitConverter.ToInt32(buffer, 8);
                    OnPropertyChanged(“Minute”);
                    Second = BitConverter.ToInt32(buffer, 12);
                    OnPropertyChanged(“Second”);
                    bytesRead = 0;
                }
                readMoreData(e);
            }
        }

If everything fine, we’ll return to wait for next message to arrive.

We done. WinForms, WPF and Silverlight speaks over the network one with another, by using TCP and UDP raw sockets. What can be better? When our message is not just clock information, but something related to gaming world (e.g. current position or state of other network players). What am I speaking about? Come to reveal it on my session DEV335: Game Development Using
Microsoft’s Latest Technologies
in TechEd Israel.

Have a nice day and be good people.

Source code for this article.

You can meet me face to face in TechEd

Starting today, if you are attending TechEd ’08 Israel, you can set an appointment with me, by using a meeting system in TechEd website. All attendees received an email with username and password to access the system. So enter, click Find and look for WPF, Silverlight or, just תמיר חסון. Then click Request to meet and that’s it.

Meet me at TechEd

Note, my free slots will be closed very soon, so, if you want to see and ask me question, hurry to close your time slot.

image

Meet me at Teched ’08 Israel >>

Recommended

 

Sponsor


Partners

WPF Disciples
Dreamhost
Code Project