creatures caves welcome, guest
downloads   gallery   dev   community   creatchi   forum   mycaves
bookmarks | search | post new topic
Development Forum
old
.net 4.0 CAOSInjector/DS CAOS Console   
ham5ter

ham5ter
Germany  

 visit ham5ter's website: Creatures.Ham5ter.de
  2/2/2013

I Build a litle .NET 4.0 CAOSInjector Class (it's written in C#) for Easy use in my Projects.

A Big Thanks goes to Chris Double. for his wonderfull documentation over here!

You can easily Dowload the Example application (a simple Dockingstation CAOS Console) and the Source here at my Server:
http://ham5ter.de/creatures/caosconsole-v0-1/

Keep in mind that the Source ist still under developement, and a Feature (Installing Scripts into the Scriptorium) is still missing!

You can use my Sourcecode for whatever you want :) if it helps you out, pls Credit me.
thx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.MemoryMappedFiles;
using System.Threading;

namespace ConsoleApplication1
{
class CaosInjector
{
static Mutex mutex;
static MemoryMappedFile memfile;
static MemoryMappedViewAccessor memviewaccessor;
static EventWaitHandle resulteventhandle;
static EventWaitHandle requesteventhandle;
public CaosInjector(string GameName){
mutex = Mutex.OpenExisting(GameName + "_mutex" );
memfile = MemoryMappedFile.OpenExisting(GameName + "_mem" );
memviewaccessor = memfile.CreateViewAccessor();
resulteventhandle = EventWaitHandle.OpenExisting(GameName + "_result" );
requesteventhandle = EventWaitHandle.OpenExisting(GameName + "_request" );
}
public string ExecuteCaosGetResult(string CaosAsString)
{
byte[] caosbytes = Encoding.UTF8.GetBytes("execute\n"+ CaosAsString +"\n" );
int bufferposition = 24;
mutex.WaitOne();
foreach (byte byt in caosbytes)
{
memviewaccessor.Write(bufferposition, byt);
bufferposition++;
}
requesteventhandle.Set();
resulteventhandle.WaitOne(5000);
int resultsize = memviewaccessor.ReadInt16(12);
byte[] resultbytes = new byte[resultsize];
for (int i = 0; i < resultsize; i++)
{
resultbytes = memviewaccessor.ReadByte(24 + i);
}
for (int i = 0; i < caosbytes.Length; i++)
{
memviewaccessor.Write(24 + i, (byte)0);
}
for (int i = 0; i < resultsize; i++)
{
memviewaccessor.Write(24 + i, (byte)0);
}
mutex.ReleaseMutex();
return Encoding.UTF8.GetString(resultbytes);
}
public int ProcessID()
{
mutex.WaitOne();
int processid = memviewaccessor.ReadInt16(4);
mutex.ReleaseMutex();
return processid;
}
}
}


moep!

 
puas

puas



  2/3/2013

hi, till now i wasn't register, and your post made me do it. :)

i have been doing something similar in my free time (not enough) so i pick your code and mix with mine.

I hope this will help you :

CAOS Console.zip

there is some exceptions left, and there aren' proprely handlet, but its litte more clear.

sorry about my english.

 
ham5ter

ham5ter


 visit ham5ter's website: Creatures.Ham5ter.de
  2/5/2013

puas wrote:
hi, till now i wasn't register, and your post made me do it. :)

i have been doing something similar in my free time (not enough) so i pick your code and mix with mine.



I am Happy that i could help you :D that is why i uploaded this here ;)
That it made you join here is also great ;)

puas wrote:

I hope this will help you :

CAOS Console.zip

there is some exceptions left, and there aren' proprely handlet, but its litte more clear.


At this state off my Shared memory research i did not think of a perfect implementation with exception handling and stuff like that :)

Thank you for your Work on that :D

puas wrote:

sorry about my english.


No Problem, i am also not a nativ speaker :)


EDIT:
I am such a lazy Guy ^^..
My Proof off Concept, worked. but your code is much better to read.
Also you added a great exception handling.
I learnd not to release some great stuff you find/made out to soon XD.


moep!

 
ham5ter

ham5ter


 visit ham5ter's website: Creatures.Ham5ter.de
  6/16/2014

Update on that Topic:

You can find the Most recent Source of the CAOS Class Library over here:
Link to BitBucket


moep!

 


downloads
cobs
adoptions
creaturelink
metarooms
breeds
 
gallery
art
wallpaper
screenshots
graphics
promos
sprites
dev
hack shack
script reservations
dev resources
active projects
dev forum
 
community
links
advice
chat
polls
resources
creatchi
 
forum
bookmarks
general
news
help
development
strangeo
survivor
mycaves
log in
register
lost pw
0 online
creatures caves is your #1 resource for the creatures artificial life game series: creatures, creatures 2, creatures 3, docking station, and the upcoming creatures family.

contact    help    privacy policy    terms & conditions    rules    donate    wiki