Tag Archives: .net

Last week I’ve created profiler tool for our new social RPG game. It’s WPF application connected via HTTP to the game server. I used MVVM pattern to decouple prety complicated workflow into several ViewModel’s. I used MVVM Light Toolkit. The main goal here is to have stable and robust implementation that would be easy to understand and change later.



There is a multiplayer server for realtime strategy game.
There is special Process thread to process behaviour of the game world.
It wake up every N milliseconds, do some changes in our object model (game world)
and then sleep for next N milliseconds.
Also, there are asynchronous network actions runned in another Socket thread.
So, the question is about synchronization.

Usually, I use ‘lock (object) { … }’ way to sync. work with data in object model.
There are a lot of locks, so, it needs to keep in mind
this multithreading nature of the server during thinking on the business logic.
As better approach, this time I implemented queue-based solution:
The Process thread may be in 3 modes:
    1) Process the world;
    2) Process the queue of collected actions;
    3) Do nothing.
Depends on the this mode, incoming Socket actions is processing like:
    1) Collected to special queue
    2) Waiting for #2 finish
    3) Process the action directly

Here is pseudocode of both methods (threads), where lock() has C# meaning.

    lock (mode)
        if (isProcess)
            lock (queue)
        } else {
            lock (process)

    lock (mode)
        isProcess := true;
    lock (process)
        lock (mode)
            isProcess := false;
        lock (queu)

As simpler desing, we can only collect actions in Socket thread
and process them only in the Process thread.
But such solution looks ugly.
In deed, we don’t need to transfer the action via queue,
we need to syncronize the process only.

Last week I finished with desing and implementation of tournaments feature of our social game about army.
Taking just raw idea of the tournament I’ve done both the server side (C#.NET+MSSQL) and the client side (Flash+ActionScript3), communication protocol, designed gameplay workflow and formalized details of UI for artist to make art. As result, there is a nice feature in the game.

One more time I have ability to prove the ability to work very productive as both the client side and the server side developer beyond the opinion of other people who claimed that it’s impossible.


Some days ago I created interactive charts in admin interface of our game project.
I tried 3 different techniques:

  • Standard MS Chart for .NET 3.5. There is MS Chart for .NET 4.0 as well, but we use 3.5 for now. Those charts generated by special handler as images on the page. There are a lot of chart types.
  • Pure HTML table with elements with different (%) width. This is the most interesting way if you need just simple diagram because you can control everything regarding your diagram. It doesn’t need special infrastructure.
  • Fusion Chart. It uses flash. There are free version and evaluation one but without trial period. Evaluation label is displayed only. I get data for the chart as XML by special .ashx handler.

For this application we decide to use Fusion Chart.

So, there is possible to treat regular ASP Panel as modal popup dialog. And even use that one as confirmation dialog instead of standard JS confirm().
I think it’s ok to use standard one in almost all case.
But if it needs custom one like in today case, then it may be used like this below.
Also, there is standard OnClienClick=”” (means regual onclick=””) to do the same but mach more easy and faster.

// ModalPopupExtender and ConfirmButtonExtender

<%– Delete Confirmation Popup Panel –%>
<asp:Panel ID=”pnlDelConfirm” runat=”server”>
Are you sure you want to delete this game?
<asp:LinkButton ID=”btnDelConfirmDelete” runat=”server” Text=”Delete” />
<asp:LinkButton ID=”btnDelConfirmCancel” runat=”server” Text=”Cancel” />

Button. We trigger confirmation on this button action.
Standard OnClientClick is used when page is still loading to provide regular JS confirm instrad of our custom ModelPopup
<asp:Button ID=”btnDelete” runat=”server” Text=”Delete” CommandName=”Delete” CausesValidation=”true”
OnClientClick=”return confirm(‘Are you sure you want to delete this game?’);” />

<atk:ConfirmButtonExtender ID=”ConfirmButtonExtender1″ runat=”server”
TargetControlID=”btnDelete” DisplayModalPopupID=”mdlDelConfirm”>

<atk:ModalPopupExtender ID=”mdlDelConfirm” runat=”server” TargetControlID=”btnDelete”
BackgroundCssClass=”modalBackground” PopupControlID=”pnlDelConfirm” OkControlID=”btnDelConfirmDelete” CancelControlID=”btnDelConfirmCancel”>

We are jumping from static .html site to new ASP.MVC version.
There are several legacy .html urls that we need to route to new controller’s methods.
Besides, we need to support new pure .html pages places in the project tree.

1. To provide legacy URL redirects (301-Permanent redirect) by URL Routing,
we mapped .html to Aspnet_isapi.dll in IIS settings of the web application.

2. Add routing for legacy URLs like:

routes.Add(new LegacyRoute(“{action}.html”, “Products”, new LegacyRouteHandler())
Constraints = new RouteValueDictionary { { “action”, “arena|gallery|construct” } }
routes.Add(new LegacyRoute(“advergames.html”, “Products”, new LegacyRouteHandler())
Defaults = new RouteValueDictionary { { “action”, “arena” } }
routes.Add(new LegacyRoute(“news2003.html”, “Company-Info-news”, new LegacyRouteHandler())
Defaults = new RouteValueDictionary { { “action”, “news” }, { “year”, “2003” } }
routes.Add(new LegacyRoute(“{game}.html”, “Games-Game”, new LegacyRouteHandler())
Defaults = new RouteValueDictionary { { “category”, “arcade” } }
Constraints = new RouteValueDictionary { { “game”, “alien-attack|alus-revenge|arcade-football” } }
routes.Add(new LegacyRoute(“{category}-games.html”, “Games-Category”, new LegacyRouteHandler())
Constraints = new RouteValueDictionary { { “category”, “arcade|card|casino” } }
routes.Add(new LegacyRoute(“games.html”, “Games-AllGames”, new LegacyRouteHandler()));
routes.Add(new LegacyRoute(“index.html”, “Root”, new LegacyRouteHandler()));

3. Process all other .html as regular pages

routes.Add(new Route(“*.html”, new StopRoutingHandler()));

4. Add Page-Not-Found routing

new { controller = “home”, action = “PageNotFound” }

5. For IIS-6 provide IHttpHandler for .html as we should process it in our ASPX application

<add path=”*.html” verb=”*” type=”System.Web.StaticFileHandler”></add>