WebSockets connection to scripting.com
Monday, November 30, 2015 by Dave Winer

Last week I posted the first update on 1999.io, the software I'm using to write this blog. It's coming along well, so it's time for a second update.

This update is for the programmers, although if you're not a programmer, you're totally welcome to listen in.

It's a floor wax and a dessert topping!

Remember that old SNL skit for Shimmer that's a floor wax that's also a dessert topping? Well 1999.io is like that. It's a blogging tool, but it's also a chat application. In fact it started as a chat app, and it became a blogging app. Basically because, as you know, everything I work on eventually becomes a blogging app. It's what I do. 

And I also like to create developer toolkits to show others how they can plug into my work, and that's what I'd like to show off today. 

A demo app

Here's a web page that contains a JavaScript app that's designed to run in the browser.

It opens a WebSockets connection with the 1999.io server, asking to listen to all the updates for the scripting channel. 

When I post something new on this blog, or someone posts or updates a comment, you'll be notified, and will get a copy of the JSON source for the post. 

You can try it out by posting a comment under this post. Modify it whenever you want to see something happen in the demo app.

Notes

  1. The code is running in the browser, but it could just as easily run on a server, in Node.js.
  2. The thing to observer is how instantaneous it is (that is if everything is working, knock wood).
  3. Here's the GitHub repository containing the source. 
  4. And here's a bookmark for the place in the code where it gets interesting. 

  • Tried to find the 'add a comment' button, only to find it buried in a dropdown. But this looks interesting. How does Google see a page like that? That's my main worry for doing extensive JavaScript in a client.

    • The Reply command is deliberately buried for now. I want to keep the drive-by abusers and spammers out until I have better moderation tools. Re Google, I put a static copy of the text in a hidden div in the page so Google would have something to index. I verified that it works. So this way we get the best of both worlds. Dynamic updating, and static content. 

    • For example, here's a Google search on this site for "floor wax dessert topping." This page is the first hit. 

      • Yes, Google has indexed this page, but that doesn't mean they will rank it. Google has long had a policy against hidden text because so many spammers use this method to be deceptive. I would worry about Google automatically assuming text in a hidden div should not be ranked. More testing is in order. :)

        • Heh. There's a lot of reasons Google doesn't like my stuff. I don't use HTTPS either. It's my problem not yours, of course. ;-)

          • No HTTPS?

  • Just trying a reply to see what happens in another browser tab...

    • Wow... very nice. The JSON that included the comment got to the tab before I could switch to it!

      • WebSockets is goooood technology as is Node.js. It's quite a stack! :-)

  • Ah, operator error. Sorry for not noticing the huge "Sign in" up there. 

  • Couldn't see the sign-in on Android mobile.  Need to look at my font size?