code postings

I have stopped work on my c# VNC like application. You can view the code on Github at https://github.com/smasherprog/Desktop_Sharing  The application is stable, but has lag spikes that occur at random times. I suspect that the problem is the garbage collector, but I dont want to go into tracking this problem down because this would be going against the language. Others might say that it is natural to have to optimize code, but the type of optimization necessary is like helping a blind man see.

So, i decided to re-write it in c++! You can check it out at https://github.com/smasherprog/RemoteDesktop The code is stable and will capture UAC, Logon log off, and regular windows operations. It is better than vnc in all of my performance/networking testing by wide margins. Additionally, it is about 10X faster than the C# equivalent code and does not have fluctuations in its running as my c# application did.

The only issue is when switching users, this causes the program to get “confused.” Once the user logs back into the desktop everything resets.  This was designed for Vista and forward.. It might work on XP, but I havent tried and dont plan on supporting an old OS.

Encryption is in place, but I have to hook it in. Within the next few days I guess. . . .

GitHub Code

I just added a new project to github; its a desktop sharing program — like VNC. So far everything is progressing nicely! There are two main projects: the viewer and the server.

To get started:

Open the project DesktopSharing_Viewer, make sure the project DesktopSharing_Viewer is set to the project starup. Then, build it. There is a text box for the IP address of the machine the server is running on to connect to.

Open the project DesktopSharing_Server, make sure the project DesktopSharingService is set to the project starup. Then, build it. There is a project called DesktopSharing_Server, which is where all of the code is, but the server is designed to be a service to run in the background so the project is set up in this way.

Run the Server on a different computer, then run the viewer on your computer and connect up.

 

backup program

I just released the start of a backup program which query’s an NTFS journal for changes. The ntfs journal is very fast for determining changes, searches and creating a file structure of the drive. With the Master File Table, an entire file count, folder count along with a complete mapping of the drive structure can be completed in less than a second.

This is the first release, and its not set up to actually do backups yet. Current, I build the file structure of a drive from the Master File Table. Next, I will query the journal to get changes which will allow me to build a list of files that need to be backed up.

Its written in C#, check it out   https://github.com/smasherprog/Backup

 

vnc proxy with websocket support

I just released a very early version of the websocket support for the VNC proxy server. It is very very unoptimized and a bit messy, but it works!. I am releasing this as a proof of concept and will clean up the code within the next few days. Check it out at https://github.com/smasherprog/VNC_Proxy

 

vnc proxy

Adding support for web sockets so the proxy can be used for regular vnc clients and web based novnc clients. Expect this within the week. . .

More code

I have released more code on github https://github.com/smasherprog

Block_SizeReporter: This will scan the directory get the file sizes and report back the best block size that should be used for the given files. When formatting a drive, sometimes you want to know what the best blocksize is to use given a certain filestructure. This is a short tool for that.

VNC_Proxy: While playing with UltraVNC, i found their repeater (aka, proxy) code to be …. not very neat. So, I wrote their repeater in c#.

Code

It has been a while since my last post as I have been working to finish up my masters degree in computer science. As of the 16 of May, I completed my degree and will now spend time actually coding for non-school projects.

I started posting code on Git Hub https://github.com/smasherprog/sl_engine

Feel Free to Jump in. My goal is to have fun creating an OpenGL 3D based Graphical Library.

Working!

I haven’t had any time to do any programming because of school and work. I want to get back to creating libraries, and updating them; however, I simply dont have the time for it. Perhaps at the end of July, I can get back to writing code. Until that time, dont expect any new code or updates.

video

In case anyone has not seen the two videos by Herb Sutter, “atomic Weapons: The C++ Memory Model and Modern Hardware,” go watch it now. It is a fantastic video that covers what atomics mean, how they are used, and where technology is supporting them. The information in this video will change your life guaranteed –or your money back!

Gems

So, I am working on integrating my UI system with my graphics system and I came across a very common problem of how to connect two completely separate modules. For example, when a model is loaded in a 3d world and the user selected the 3d model, I want have a tool pop up that is connected to the 3d model.

The tool can be position, scaling, texture info…. what ever. The point is that the GUI has some general purpose widgets like sliders that would be great to hook into the object in the world and update themselves. Well, if I pass the widget the memory address of the position, as floats, then I can keep the GUI decoupled — perfect. But, what happens when the 3d object is destroyed, how will the GUI widget know and take appropriate action? If the widget tries to read from the memory after the 3d object is destroyed, there will be an error.

One solution is to create some type of event manager that is tied into all parts of the program and acts as the glue. Then all of these objects: the GUI widget and the 3d object can communicate through this “middle man” and our safe communication can be achieved. When a 3d object is destroyed, it cal tell the event manager, which can then pass that message along to other objects that are listening for it. I really really don’t like this type of a plan. see http://www.gamedev.net/topic/638088-global-event-manager-system/ for a little discussion on the negatives posted by Hodgman, which I agree with.

Having said that, I came up with a simple solution which you can view here Signal.h

So, what is this? First, you need to be using a c++ 11 compliant compiler and with visual studio that means compiling using the nov compiler CTP you can get here http://www.microsoft.com/en-us/download/details.aspx?id=35515

So, here is the basic idea of the Signal class.

You have Library A and Library B of which neither know anything about the other. For example, a GUI and an in game 3d object. You want the widget to display the 3d objects position in the game world. Well, imagine if that 3d object is an NPC in a video game and it is walking around. Your widget needs a way to know when that 3d object has moved and act appropriately.

Also, it would be nice if this way was SIMPLE and didnt require any global managers, or any other fancy trickery. Enter my Signal class Signal.h

Below is a simple example of how to use it to glue together your libraries. In the example below the objects call the others functions. When one is destructed, the link is removed. You can connect as many objects together as you like.

class object_3d{
public:
	object_3d(){x=y=z=0.0f;}
	~object_3d(){
		On_Destruction.Call();
	}
	void  MoveTo(float newx, float newy, float newz){
		x =newx;	
		y =newy;
		z =newz;
		On_Moved.Call(x, y, z);// let anyone listening know that this object has moved
	}

	float x, y, z;// object_3d's position

	MY_Utilities::Signal_st<void, float, float, float> On_Moved;
	MY_Utilities::Signal_st<void> On_Destruction;
};

class gui_widget{
public:
	gui_widget(){x=y=z=0;}
	~gui_widget(){On_Destruction.Call();}

	void Update(float nx, float ny, float nz){
		x=nx;
		y=ny;
		z=nz;
		On_Update.Call(x, y, z);//let anyone who is bound to this know that the GUI changed the objects coords. So, the On_Update.call will let the object know
	}

	float x, y, z;

	MY_Utilities::Signal_st<void> On_Destruction;
	MY_Utilities::Signal_st<void, float, float, float> On_Update;
};

int main(int argc, char* argv[])
{
	object_3d obj;
	gui_widget widget;

	obj.On_Moved.Connect(&widget.On_Update, std::bind(&gui_widget::Update, &widget, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
}

If you look in the example you might think that I created an infinite loop. When the 3d object calls On_Moved in the MoveTo Function, the guiwidgets Update function will be called. BUT WAIT, the Update function calls the 3d objects MoveTo — theres an infinite loop! Take a look in the Call Code of the signal class. In fact, ill post it here

		void Call(T... params){
			if(_Is_Calling) return;//avoid infinite recursion
			_Is_Calling = true;
			for(auto i=Slots.begin(); i!= Slots.end(); i++){
                               if((*i).first->Is_Calling()) continue;
			       (*i).second(params...);
			}
			_Is_Calling = false;
		}

If you see, when Call is called _Is_Calling is set to true, then for each connection, the remote function is checked to see if it is calling. If it is, the slot is skipped because all of the connections are a 1 to 1 so this check prevents infinite recursion.

When the Signal destructor is called, the connections are cleared on both ends. There is a st(single thread) version and an mt(Multi-thread) version. Of course, the single threaded is faster because there are no locks.