================================================================================ PAGE 91 ================================================================================ 2.)ChangetheplatformsettingstogenerateX86codeifitisnotalreadyset. IntheConfiguration ManagerselectPlatform ->New->X86andusethisplatformforthe DebugandReleaseconfigurations. ================================================================================ PAGE 92 ================================================================================ 3.)ChangetheOutputpathofyourproject. Theapplication needsthefollowingfilesinitspath:GeviProcAPI.dll ,GscDBI.dll ,GscAc- tions.dll ,GeViProcAPINET_ X_Y.dll,andGscActionsNET_ X_Y.dll.Allthesefilesarein your%GEVISOFTSDKPATH% ,sotheoutputpathtoc:\gevisoft\ . TochangetheOutputpath,eitherright-clickonyourprojectinSolution Explorerandpress Properties orchooseProject->ProjectName Properties fromthemenu.ThenselecttheBuild tabandsetyourOutputpath. ================================================================================ PAGE 93 ================================================================================ ================================================================================ PAGE 94 ================================================================================ 4.)Addtherequiredusingdirectives toyourproject’ssourcefiles. ForaprojectthatonlyusesGeViSoftactions,youneedatleast. GEUTEBRUECK.GeViSoftSDKNET.ActionsWrapper aswellas GEUTEBRUECK.GeViSoftSDKNET.ActionsWrapper.ActionDispatcher and,additionally foractionsfromeveryactionclassyouuse, GEUTEBRUECK.GeViSoftSDKNET.ActionsWrapper.YourActionClass IfyoualsowanttouseGeViScope actions,makesuretoinclude GEUTEBRUECK.GeViScope.Wrapper.Actions.ActionDispatcher and GEUTEBRUECK.GeViScope.Wrapper.Actions.YourActionClass Youcanfinddescriptions oftheactionsandtheirrespective actionclassesintheAPIdoc- umentation orbyinspecting theassemblies withtheObjectBrowser. VisualStudio2010,C# Configure yourprojectasdescribed inparagraph VisualStudio2008,C# Common TaskswithC# Thischapterdescribes severalcommontasksyoumightneedtocarryoutduringyourdevel- opment.Thetasksaredescribed inpseudocodeandC#. ================================================================================ PAGE 95 ================================================================================ Connecting toaGeViServer Thisparagraph showsyouwhattasksareneededforconnecting toaGeViServer. Connecting PseudoCode 1.Implement theconnectcallbackmethod 2.Createaninstanceofadatabaseconnection object 3.Callthecreate()methodofyourdatabaseconnection object 4.Addyourcallbackdelegatemethodtotheinvocation list 5.Registeryourcallbackmethod 6.Calltheconnectmethodofyourdatabaseconnection object C# //Thisistheconnect progress callback method. //ItiscalledfromwithinGeViSoft duringtheconnection progress voidmyConnectProgress (objectsender, GeViSoftConnectProgressEventArgs e) { Console.WriteLine ("Connecting... {0}of{1}",e.Progress, e.Effort); } //myDBisthedatabase objectthatencapsulates //allGeViSoft interaction. GeViDatabase myDB=newGeViDatabase (); //Settheservername,usernameandpassword ofyour //GeViSoft connection myDb.Create ("localhost", "sysadmin", "masterkey" ); ================================================================================ PAGE 96 ================================================================================ //Addyourcallback delegate totheinvocation list myDb.ConnectProgress +=newGeViSoftConnectProgressEventHandler ( myConnectProgress); //Register thecallback insideGeViSoft myDb.RegisterCallback (); //Nowyoucanconnect totheGeViSoft Server... myDB.Connect (); Astraightforward implementation forestablishing aconnection canbefoundinexampleCS_ ConsoleClient . Message Handling Afterhavingestablished theconnection, youarereadytoexchange messages andactions withtheserver. Creating andSending ofGeViSoft Messages Therearetwoapproaches thatcanbetakentocreateandsendGeViSoftmessages. Youcan eithercreateamessageinstancebycallingitsconstructor andthensendthisinstance,or youcandirectlysendastringrepresentation ofamessagewithoutinstantiating itfirst. Example 1–Creating aninstance ofamessage andsending itafter- wards //CreateaCrossSwitch Actionandswitch //input7tooutput1 GeViAct_ CrossSwitch myAction =newGeViAct_ CrossSwitch ( 7,1,GeViTSwitchMode.sm_ Normal); //Sendtheaction ================================================================================ PAGE 97 ================================================================================ myDB.SendMessage (myAction);  NOTICE Makesureyouhaveincludedyouraction’scorresponding actionclassnamespace inyour usingdirectives. SeeConfiguring yourIDEforGeViSoft.Net Projects->VS2008,C# Example 2–Directly sending amessage fromastring myDB.SendMessage ("CrossSwitch (7,1,0)"); Receiving ofGeViSoft Actions GeViSoftactiondispatching iseventbased.Internally, foreveryactionthatisreceived,an eventisfired.IfyouwanttoprocesscertainGeViSoftactionmessages insideyourappli- cation,youcanregisteraneventhandlerforthisparticularaction.Theeventhandleriscalled whenever anewactionofthattypeisreceived. IfyouwanttoprocessCrossSwitch actionsinyourapplication, youcanproceedasshownin thisexample. Pseudocode: 1.Implement amethodthatiscalledwhenever theeventisfired(actionreceived) 2.Registeryourmethodasaneventhandlerfortheparticularaction 3.RegisteryoureventhandlerinsidetheGeViSoftconnection object. C#: //Methodtobecalledonreceiving aCrossSwitch Action voidmyDB_ReceivedCrossSwitch (objectsender, GeViAct_ CrossSwitchEventArgs e) { ================================================================================ PAGE 98 ================================================================================ StringreceivedMessage ="CrossSwitch ("+ e.aVideoInput +","+ e.aVideoOutput +","+ e.aSwitchMode +")"; } //Eventhandler forCrossSwitch Actions myDB.ReceivedCrossSwitch +=new GeViAct_ CrossSwitchEventHandler (myDB_ReceivedCrossSwitch); //Don’tforgettoregister thehandler insidetheGeViSoft connection object myDB.RegisterCallback (); Receiving ofGeViSoft Notifications Besidesactions,GeViSoftalsosendsmessages regardingtheserverstatus,thedatabase notifications. Youcanreceivethesenotifications byregistering aGeV- iSoftDatabaseNotificationEventHandler. Theprocedure issimilartotheactionsubscription asdescribed above. Hereisanexample: voidmyDB_DatabaseNotification (objectsender, GeViSoftDatabaseNotificationEventArgs e) { switch(e.ServerNotificationType) { caseGeViServerNotification .NFServer_ Disconnected: //("Disconnected fromServer"); break; caseGeViServerNotification .NFServer_ GoingShutdown: //("Server isshutting down"); break; ================================================================================ PAGE 99 ================================================================================ caseGeViServerNotification .NFServer_ SetupModified: //("Server setuphasbeenmodified"); break; caseGeViServerNotification .NFServer_ NewMessage: //An“ordinary” actionhasbeenreceived. //Handlethisactioninaseparate Event- Handler //(likemyDB_ReceivedCrossSwitchAction) break; } } //Youregister thehandler asdescribed before myDB.DatabaseNotification +=new GeViSoftDatabaseNotificationEventHandler (myDB_DatabaseNotification); myDB.RegisterCallback ();  NOTICE Pleasenotethatthee.ServerNotificationType equalsGeViServerNotification .NFServer_ New- Message witheveryGeViSoft actionthatisreceived, regardless ifyoualready subscribed forit withanother eventhandler. Handling ofGeViScope Actions YoucanalsosendGeViScope actionsfromyourGeViSoftapplication. SendingGeViScope actionsisverysimilartosendingGeViSoftactions.Theonlydifference isthatyouneedto addtheGeViScope serveraliastotheSendMessage ()method’sparameters. Sending GeViScope Actions Example–sendingaGeViScope message: ================================================================================ PAGE 100 ================================================================================ Prerequisite: 1.Connection toGeViScope hasbeenconfigured withGeViSet 2.Theappropriate namespaces areincluded //Example forGeViScope namespace neededtohandle //aGeViScope CustomAction usingGEUTEBRUECK.GeViScope.Wrapper.Actions; usingGEUTEBRUECK.GeViScope.Wrapper.Actions.SystemActions; //CreatetheGeViScope action GscAct_CustomAction myGscAction =new GscAct_CustomAction (23,"HelloGeViScope!" ); //SendtheActiontothe“GeViScope_ Alias”server myDB.SendMessage ("GEVISCOPE_ ALIAS",myGscAction); Receiving GeViScope Actions Receiving GeViScope actionsisalittledifferentfromhandlingGeViSoftactions.Duetoarchi- tecturalconstraints, whenever aGeViSoftActionarrives,itisencapsulated intoaspecial GeViSoftaction.ThisactioniscalledGscAction. TheGscAction itselfisretrievedlikeanyotherGeViSoftactionbyimplementing amethod thatprocesses theGscAction andthatisaddedasaneventhandlerforreceivingtheGscAc- tion. ThismethodreceivestheoriginalGeViScope Actionembedded intoitsEventArgs whenever itiscalled. NormallyyouthenwouldhavetoidentifyandparsetheGeViScope actionandhandleitas neededbyhand.Foryourconvenience, theGeutebrueck SDKsprovideyouwithadispatcher thatcansimplifythattask: ThereisaDispatcher methodforGeViScope actionsthatworksverysimilartothedis- patchingmechanism usedbyGeViSoft. YoucansimplyaddeventhandlersfortheGeV- iScopeactionsyouareinterested inandprocesstheminthere.