<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-28269405</id><updated>2011-10-06T10:03:23.674-04:00</updated><category term='WebSockets'/><category term='HTML5'/><title type='text'>A C# Coder's World</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://acsharpcodersworld.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28269405/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://acsharpcodersworld.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>jkworth</name><uri>http://www.blogger.com/profile/06733079832228650222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-28269405.post-6784339523021680783</id><published>2010-12-10T14:53:00.008-05:00</published><updated>2010-12-10T18:06:05.638-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WebSockets'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML5'/><title type='text'>WebSockets</title><content type='html'>It's been a really long time since I made a post on my blog, but lately I had to do some work that resulted in me implementing a draft spec of the WebSocket protocol. I have noticed that there is a lot of talk about them due to the development of HTML5. So I sat down with the latest draft spec for the &lt;b&gt;WebSocket protocol&lt;/b&gt;, &lt;a href="http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-03"&gt;draft-ietf-thewebsocketprotocol-03&lt;/a&gt;, and began implementing a solution that more completely represented the spec and was also usable.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;While I wanted to implement the full spec, I did decide to leave out a few parts. I did not implement support for Framing, which at the time of writing is not possible from the &lt;b&gt;WebSocket API&lt;/b&gt; for JavaScript. Since my implementation was intended to communicate with browsers, and the API does not have a way for JS code to tell the socket to send data Framed. Because of that, I left it out. I have also not added support for &lt;b&gt;wss&lt;/b&gt;, encrypted connections. I will add this at a later time.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So lets get to what I did implement. The &lt;b&gt;WebSocketServer &lt;/b&gt;class can listen on a defined IP and port. It will listen for connection attempts and Create &lt;b&gt;WebSocket &lt;/b&gt;objects to handle each connection. So unlike a number of sources on the net, this will handle multiple connections at one time. At this time I have not set a limit to the number of them that can be open at one time. The &lt;b&gt;WebSocket &lt;/b&gt;class handles the connection from that point on. It will perform the handshake response to the client to establish a good connection. I will then listen for data from the client and raise an event when a complete message has been received. It also provides a way to send data to the client. The code also takes care of dropped connections by cleaning up after a connection failure.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The current code can be found &lt;a href="http://www.mediafire.com/?jdk0c4eut4wmpc8"&gt;here&lt;/a&gt;. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let me know any suggestions you may have.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28269405-6784339523021680783?l=acsharpcodersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://acsharpcodersworld.blogspot.com/feeds/6784339523021680783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28269405&amp;postID=6784339523021680783&amp;isPopup=true' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28269405/posts/default/6784339523021680783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28269405/posts/default/6784339523021680783'/><link rel='alternate' type='text/html' href='http://acsharpcodersworld.blogspot.com/2010/12/websockets.html' title='WebSockets'/><author><name>jkworth</name><uri>http://www.blogger.com/profile/06733079832228650222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28269405.post-5025691277865402087</id><published>2007-02-05T10:21:00.000-05:00</published><updated>2007-02-08T21:45:22.732-05:00</updated><title type='text'>Problems with learning to code through code reuse</title><content type='html'>&lt;div style="text-align: justify; font-size: 85%;"&gt;I've come to the conclusion that while code reuse is a great thing to speed up development.  It does not allow developers who are trying to learn a new skill to truly learn that skill.&lt;br /&gt;&lt;br /&gt;An example would be that developers are continuously using String objects instead of StringBuilder objects when doing multiple concatenations and modifications.  They have no idea why their code runs slow.  You can't learn something if you don't take the time to understand it. So a lot of beginners do not know why StringBuilder is better than a String, or that in some cases just the opposite can be true, or what to look for on deciding which one to use.  Some even have no idea on what &lt;a href="http://en.wikipedia.org/wiki/Immutable_object"&gt;immutable&lt;/a&gt; means.&lt;br /&gt;&lt;br /&gt;There appears to be some disconnect these days with users who don't care to learn the basics.  Part of this is due to the fact that you can build something with .NET so easy, and you don't have to know the inner workings.  I find this very disheartening.  Everyone wants short cuts but when you bypass this information your only setting yourself up for disaster.&lt;br /&gt;&lt;br /&gt;So, with that I have a few suggestions for the individual who wants to know more about .NET.  Start with the &lt;a href="http://msdn2.microsoft.com/en-us/library/ddk909ch.aspx"&gt;CLR&lt;/a&gt; and learn what it is and how your code is really compiled and what &lt;a href="http://en.wikipedia.org/wiki/Common_Intermediate_Language"&gt;MSIL&lt;/a&gt; is.  Learn about the &lt;a href="http://msdn2.microsoft.com/en-us/library/f144e03t.aspx"&gt;Garbage Collector&lt;/a&gt;. Learn what the &lt;a href="http://en.wikipedia.org/wiki/Just-in-time_compilation"&gt;JIT&lt;/a&gt; compiler is.  Learn what &lt;a href="http://en.wikipedia.org/wiki/Mutable"&gt;mutable&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Mutable"&gt;immutable&lt;/a&gt; types are.  Understand why &lt;a href="http://www.codeproject.com/csharp/foreach.asp"&gt;"for" loops are better than "foreach" loops&lt;/a&gt;.  Know what &lt;a href="http://msdn2.microsoft.com/en-us/library/0f66670z.aspx"&gt;pass by reference&lt;/a&gt; is.&lt;br /&gt;&lt;br /&gt;This list is by no means complete but should be a good place to start.  Enjoy and good luck.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28269405-5025691277865402087?l=acsharpcodersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://acsharpcodersworld.blogspot.com/feeds/5025691277865402087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28269405&amp;postID=5025691277865402087&amp;isPopup=true' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28269405/posts/default/5025691277865402087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28269405/posts/default/5025691277865402087'/><link rel='alternate' type='text/html' href='http://acsharpcodersworld.blogspot.com/2007/02/problems-with-learning-through-code.html' title='Problems with learning to code through code reuse'/><author><name>jkworth</name><uri>http://www.blogger.com/profile/06733079832228650222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28269405.post-4475608014081106651</id><published>2007-02-02T12:31:00.000-05:00</published><updated>2007-02-02T12:52:01.896-05:00</updated><title type='text'>No Oracle DLinq Support</title><content type='html'>&lt;div style="text-align: justify; font-size: 85%;"&gt;Recently I had a chance to play around with DLINQ that came out in the "Microsoft Visual Studio Code Name “Orcas” - LINQ CTP (May 2006)".  I was blown away by the ability to create a Data Access Layer with out writing a single sql statement.&lt;br /&gt;&lt;br /&gt;DLINQ stands for &lt;b&gt;D&lt;/b&gt;atabase &lt;b&gt;L&lt;/b&gt;anguage &lt;b&gt;IN&lt;/b&gt;line &lt;b&gt;Q&lt;/b&gt;uery.  What this means is that we no longer have to write sql statements as strings but can compile them as constructs of the application and let the provider module build the proper query for us at execution time based on the IL that was generated.  Seeing this in action was unbelievable.&lt;br /&gt;&lt;br /&gt;I spent a good bit of time reading all the material and examples and just couldn't wait until I could try it out with Oracle.  It didn't take me long to determine that there was no Oracle support built in to the product.  The reading that I did did point out that there is a framework in place for any provider to create their own LINQ module.  As of yet, I have found no information stating that Oracle is or plans on making an Oracle DLINQ provider.&lt;br /&gt;&lt;br /&gt;For those of us Oracle Developers out there this is a must have in the future.  Hopefully Oralce will not make us wait too long for it.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28269405-4475608014081106651?l=acsharpcodersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://acsharpcodersworld.blogspot.com/feeds/4475608014081106651/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28269405&amp;postID=4475608014081106651&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28269405/posts/default/4475608014081106651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28269405/posts/default/4475608014081106651'/><link rel='alternate' type='text/html' href='http://acsharpcodersworld.blogspot.com/2007/02/linq.html' title='No Oracle DLinq Support'/><author><name>jkworth</name><uri>http://www.blogger.com/profile/06733079832228650222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28269405.post-116169987497589606</id><published>2006-10-24T09:52:00.000-04:00</published><updated>2006-10-24T19:58:39.546-04:00</updated><title type='text'>.Net 2.0 and JavaScript</title><content type='html'>&lt;div style="text-align:justify;font-size:85%;" &gt;Up until now, most sites built by ASP.NET developers have had post-backs to manipulate the user interface to provide some feedback to the user.  This was probably due to the lack of JavaScript knowledge.  Due to recent activity on the use of AJAX, its hard not to need JavaScript in almost any web site today.  This brings me to my discovery.&lt;br /&gt;&lt;br /&gt;I have been working on a project and my clients most recent request has been to eliminate page refreshes due to post-backs.  Of course I said no problem and went about  the process of using the ICallbackEventHandler interface to utilize what .NET has provided.  To do this requires the writing of many JavaScript functions, which almost all need some reference to one or more controls on the UI.  No big deal you say.  That's what I said when I started this process.  Then I realized that all of the controls have a an ID on the server and an ID on the client side which are different.  The problem arose when I needed to reference a text field called "UserID".  In the C# code its no problem getting to this object but client side, the "document.getElementById('UserID')" was not returning anything but null.&lt;br /&gt;&lt;br /&gt;It took very little time to figure out why this was happening.  The control emit a unique id to the client to make sure that all controls are unique.  So my "UserID" control ended up with an ID of "ctl00_ctl00_PageContent_Content_UserID".  Once I determined this it was easy for the "document.getElementById()" to find the proper control.  The only problem was that I was going to have to render every page to find out what the final ID was going to be for each control and if anything changed to alter the hierarchy then that meant the IDs could change.&lt;br /&gt;&lt;br /&gt;I was having a field day complaining about why Microsoft would do this and how I was going to create an affective way to handle this.  I went through a few different ideas before realizing that all of the control are nested and could be traversed.&lt;br /&gt;&lt;br /&gt;I then decided that since I have a master page, that all pages were using, I could use code in the master page to find all controls on any page that used it.  Since I know about all of the controls before the page gets rendered, why not emit some JavaScript to reference all of the controls.&lt;br /&gt;&lt;br /&gt;First I declared an ArrayList to hold some info:&lt;pre style="color: #000099"&gt;&lt;br /&gt;ArrayList jsControls = new ArrayList();&lt;/pre&gt;&lt;br /&gt;Then I added some code to my Master Pages "Page_Load" event handler:&lt;pre style="color: #000099"&gt;&lt;br /&gt;this.loadJsControls( this.Page );&lt;br /&gt;jsControls.Sort();&lt;br /&gt;this.Page.ClientScript.RegisterStartupScript(&lt;br /&gt;   this.Page.GetType(),&lt;br /&gt;   "vars",&lt;br /&gt;   string.Join( "", ((string[])jsControls.ToArray(typeof(string)))),&lt;br /&gt;   true );&lt;/pre&gt;&lt;br /&gt;This calls a custom recursive function that loads the ArrayList:&lt;pre style="color: #000099"&gt;&lt;br /&gt;private void loadJsControls( Control control ) {&lt;br /&gt;&lt;br /&gt;    if ( control is HtmlImage || control is HtmlInputControl ||&lt;br /&gt;         control is HtmlContainerControl || control is WebControl ) {&lt;br /&gt;&lt;br /&gt;        if ( control.ID != null &amp;amp;&amp;amp; control.ID.Length &gt; 0 &amp;amp;&amp;amp;&lt;br /&gt;             !control.ID.StartsWith( "Image" ) &amp;amp;&amp;amp; &lt;br /&gt;             control.ClientID != null &amp;&amp;amp; &lt;br /&gt;             control.ClientID.Length &gt; 0 ) {&lt;br /&gt;          &lt;br /&gt;            jsControls.Add(&lt;br /&gt;                "var " + control.ID + &lt;br /&gt;                " = document.getElementById( \"" + &lt;br /&gt;                control.ClientID + "\" );\n" );&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    for ( int i = 0; i &amp;lt; control.Controls.Count; i++ ) {&lt;br /&gt;        loadJsControls( control.Controls[ i ] );&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;Here is an example of the results produced by this:&lt;pre style="color: #000099"&gt;&lt;br /&gt;&amp;lt;script type="text/javascript"&gt;&lt;br /&gt;&amp;lt;!--&lt;br /&gt;var changePAsswordLink = document.getElementById(&lt;br /&gt;    "ctl00_ctl00_PageContent_header_ctl13_changePAsswordLink" );&lt;br /&gt;var closeLink = document.getElementById(&lt;br /&gt;    "ctl00_ctl00_PageContent_header_ctl13_closeLink" );&lt;br /&gt;var exportLink = document.getElementById(&lt;br /&gt;    "ctl00_ctl00_PageContent_header_ctl13_exportLink" );&lt;br /&gt;var UserID = document.getElementById(&lt;br /&gt;    "ctl00_ctl00_PageContent_Content_UserID" );&lt;br /&gt;// --&gt;&lt;br /&gt;&amp;lt;/script&gt;&lt;/pre&gt;&lt;br /&gt;This allows my JavaScript to not need to look up the control but only know the server side name.  Here is an example:&lt;pre style="color: #000099"&gt;&lt;br /&gt;UserID.value = "Joe Blow";&lt;/pre&gt;&lt;br /&gt;This is possible due to the fact that the JavaScript declarations happen after the page loads so each one already points to the proper control.&lt;br /&gt;&lt;br /&gt;I hope this will at least help one other developer.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28269405-116169987497589606?l=acsharpcodersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://acsharpcodersworld.blogspot.com/feeds/116169987497589606/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28269405&amp;postID=116169987497589606&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28269405/posts/default/116169987497589606'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28269405/posts/default/116169987497589606'/><link rel='alternate' type='text/html' href='http://acsharpcodersworld.blogspot.com/2006/10/net-20-and-javascript.html' title='.Net 2.0 and JavaScript'/><author><name>jkworth</name><uri>http://www.blogger.com/profile/06733079832228650222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-28269405.post-115108958969226840</id><published>2006-06-23T15:06:00.000-04:00</published><updated>2006-10-24T19:58:39.427-04:00</updated><title type='text'>Leverage the C# Preprocessor</title><content type='html'>&lt;a href="http://blogs.msdn.com/csharpfaq/archive/2004/10/20/245316.aspx"&gt;Leverage the C# Preprocessor&lt;/a&gt;: "Like other languages in the C-family, C# supports a set of 'preprocessor' directives, most notably #define, #if and #endif (technically, csc.exe does not literally have a preprocessor as these symbols are resolved at the lexical analysis phase, but no need to split hairs…). &lt;br /&gt;&lt;br /&gt;The #define directive allows you to set up custom symbols which control code compilation. Be very aware that unlike C(++), C#'s #define does not allow you to create macro-like code. Once a symbol is defined, the #if and #endif maybe used to test for said symbol. By way of a common example:&lt;br /&gt;&lt;br /&gt;#define DEBUG using System; public class MyClass { public static void Main() { #if DEBUG Console.WriteLine('DEBUG symbol is defined!'); #endif } }&lt;br /&gt;&lt;br /&gt;When you use the #define directive, the symbol is only realized within the defining file. However if you wish to define project wide symbols, simply access your project's property page and navigate to the 'Configuration Properties | Build' node and edit the 'Conditional Compilation "&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/28269405-115108958969226840?l=acsharpcodersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://acsharpcodersworld.blogspot.com/feeds/115108958969226840/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=28269405&amp;postID=115108958969226840&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/28269405/posts/default/115108958969226840'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/28269405/posts/default/115108958969226840'/><link rel='alternate' type='text/html' href='http://acsharpcodersworld.blogspot.com/2006/06/leverage-c-preprocessor.html' title='Leverage the C# Preprocessor'/><author><name>jkworth</name><uri>http://www.blogger.com/profile/06733079832228650222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
