/// <summary> /// Only constructor. /// </summary> /// <param name="ChanKind"></param> /// <param name="ObjType"></param> /// <param name="CallConv"></param> /// <param name="InvKind"></param> public Client(ChannelKind ChanKind, Type ObjType, CallingConvention CallConv, InvokeKind InvKind, string Host) { m_ChanKind = ChanKind; m_ObjType = ObjType; m_CallConv = CallConv; m_InvKind = InvKind; m_Host = Host; }//constructor
/// <summary> /// Runs this program as a server. /// </summary> public static void Run(ChannelKind ChanKind, WellKnownObjectMode ObjMode, Type ObjType) { TcpChannel tcpchan; HttpChannel httpchan; System.Collections.Hashtable httpproperties; System.Collections.Hashtable tcpproperties; Console.WriteLine("\nStarting server in WellKnownObjectMode {0}\n", ObjMode.ToString()); switch (ChanKind) { case ChannelKind.Http: httpproperties = new System.Collections.Hashtable(); httpproperties["port"] = Server.HTTPPORT; httpchan = new HttpChannel(httpproperties, null, GetProviderChain()); ChannelServices.RegisterChannel(httpchan); break; case ChannelKind.TCP: tcpproperties = new System.Collections.Hashtable(); tcpproperties["port"] = Server.TCPPORT; tcpchan = new TcpChannel(tcpproperties, null, GetProviderChain()); ChannelServices.RegisterChannel(tcpchan); break; case ChannelKind.Both: httpproperties = new System.Collections.Hashtable(); httpproperties["port"] = Server.HTTPPORT; httpchan = new HttpChannel(httpproperties, null, GetProviderChain()); ChannelServices.RegisterChannel(httpchan); tcpproperties = new System.Collections.Hashtable(); tcpproperties["port"] = Server.TCPPORT; tcpchan = new TcpChannel(tcpproperties, null, GetProviderChain()); ChannelServices.RegisterChannel(tcpchan); break; default: throw new System.InvalidOperationException("Unexpected Channel kind in Server.Run()"); }//switch RemotingConfiguration.RegisterWellKnownServiceType(ObjType, "SayHello", ObjMode); System.Console.WriteLine("Hit <enter> to exit..."); System.Console.ReadLine(); return; }
private Func <AnimFlags> ChooseChannel(ChannelKind kind) { switch (kind) { case ChannelKind.Backward: case ChannelKind.Forward: case ChannelKind.Right: case ChannelKind.Left: return(DirectionalMove(kind)); break; } return(IdleCycle); }
public static string ToApiString(this ChannelKind value) { switch (value) { case ChannelKind.PublicChannel: return(PUBLIC_CHANNEL); case ChannelKind.PrivateChannel: return(PRIVATE_CHANNEL); case ChannelKind.DirectMessage: return(DIRECT_MESSAGE); } return(value.ToString("G").ToLower()); }
private Func <AnimFlags> DirectionalMove(ChannelKind mainChannel) { AnimFlags l_direction = AnimFlags.idle1; switch (mainChannel) { case ChannelKind.Forward: l_direction = AnimFlags.run; break; case ChannelKind.Backward: l_direction = AnimFlags.run_bk; break; case ChannelKind.Left: l_direction = AnimFlags.ss_lt; break; case ChannelKind.Right: l_direction = AnimFlags.ss_rt; break; } bool l_switchCase = false; return(() => { m_currentRoutine = () => { Func <AnimFlags> l_exitScenario = () => { m_currentRoutine = IdleCycle; return AnimFlags.stepb; }; Func <AnimFlags> l_stopScenario = () => { m_currentRoutine = IdleCycle; return AnimFlags.stop; }; Func <AnimFlags> l_loop = () => { return l_direction | (m_plch[mainChannel] ? ((l_switchCase = !l_switchCase) ? AnimFlags.rt : AnimFlags.lt) : l_stopScenario()); }; Func <AnimFlags> l_loopEnter = () => { m_currentRoutine = l_loop; return AnimFlags.start; }; return l_direction | (m_plch[mainChannel] ? l_loopEnter : l_exitScenario)(); }; return l_direction | AnimFlags.stepa; }); }
}//Usage() /// <summary> /// Gets user options. /// </summary> private static void GetOptions() { GetChannel: Console.Write("\nHttp (h), TCP (t) or both (b) using threads? "); string Reply = Console.ReadLine(); switch (Reply.ToLower()) { case "b": m_ChanKind = ChannelKind.Both; break; case "h": m_ChanKind = ChannelKind.Http; break; case "t": m_ChanKind = ChannelKind.TCP; break; default: Console.WriteLine("Invalid option, please try again."); goto GetChannel; }//switch GetConvention: Console.Write("\nBy ref (r) or by val (v)? "); Reply = Console.ReadLine(); switch (Reply.ToLower()) { case "r": m_CallConv = CallingConvention.ByRef; break; case "v": m_CallConv = CallingConvention.ByVal; break; default: Console.WriteLine("Invalid option, please try again."); goto GetConvention; }//switch GetInvoke: Console.Write("\nSerial (s) or async (a)? "); Reply = Console.ReadLine(); switch (Reply.ToLower()) { case "a": m_InvKind = InvokeKind.Async; break; case "s": m_InvKind = InvokeKind.Sequential; break; default: Console.WriteLine("Invalid option, please try again."); goto GetInvoke; }//switch //Setup the correct Type object to pass to the Client object for object creation. switch (m_CallConv) { case CallingConvention.ByRef: m_ObjType = Type.GetType("RemotingSamples.HelloServerByRef,remotingshared"); break; case CallingConvention.ByVal: m_ObjType = Type.GetType("RemotingSamples.HelloServerByVal,remotingshared"); break; default: throw new System.InvalidOperationException("Invalid Calling Convention in Main()"); }//switch Console.WriteLine(); return; }//GetOptions()
}//Usage() /// <summary> /// Determines whether to act as client or server and executes the relevant method. /// </summary> private static void GetOptions() { GetChannel: Console.Write("\nHttp (h), TCP (t) or both (b)? "); string Reply = Console.ReadLine(); switch (Reply.ToLower()) { case "b": m_ChanKind = ChannelKind.Both; break; case "h": m_ChanKind = ChannelKind.Http; break; case "t": m_ChanKind = ChannelKind.TCP; break; default: Console.WriteLine("Invalid option, please try again."); goto GetChannel; }//switch GetObjectMode: Console.Write("\nSingleCall (sc) or Singleton (st)? "); Reply = Console.ReadLine(); switch (Reply.ToLower()) { case "sc": m_ObjMode = WellKnownObjectMode.SingleCall; break; case "st": m_ObjMode = WellKnownObjectMode.Singleton; break; default: Console.WriteLine("Invalid option, please try again."); goto GetObjectMode; }//switch GetConvention: Console.Write("\nBy ref (r) or by val (v)? "); Reply = Console.ReadLine(); switch (Reply.ToLower()) { case "r": m_CallConv = CallingConvention.ByRef; break; case "v": m_CallConv = CallingConvention.ByVal; break; default: Console.WriteLine("Invalid option, please try again."); goto GetConvention; } //switch return; } //GetOptions()
}//Usage() /// <summary> /// Determines whether to act as client or server and executes the relevant method. /// </summary> private static void GetOptions() { GetChannel: Console.Write("\nHttp (h), TCP (t) or both (b)? "); string Reply = Console.ReadLine(); switch (Reply.ToLower()) { case "b": m_ChanKind = ChannelKind.Both; break; case "h": m_ChanKind = ChannelKind.Http; break; case "t": m_ChanKind = ChannelKind.TCP; break; default: Console.WriteLine("Invalid option, please try again."); goto GetChannel; }//switch GetObjectMode: Console.Write("\nSingleCall (sc) or Singleton (st)? "); Reply = Console.ReadLine(); switch (Reply.ToLower()) { case "sc": m_ObjMode = WellKnownObjectMode.SingleCall; break; case "st": m_ObjMode = WellKnownObjectMode.Singleton; break; default: Console.WriteLine("Invalid option, please try again."); goto GetObjectMode; }//switch GetConvention: Console.Write("\nBy ref (r) or by val (v)? "); Reply = Console.ReadLine(); switch (Reply.ToLower()) { case "r": m_CallConv = CallingConvention.ByRef; break; case "v": m_CallConv = CallingConvention.ByVal; break; default: Console.WriteLine("Invalid option, please try again."); goto GetConvention; }//switch return; }//GetOptions()
}//GetOptions() /// <summary> /// Runs this program as a server. /// </summary> public static void Run(ChannelKind ChanKind, WellKnownObjectMode ObjMode, Type ObjType) { TcpChannel tcpchan; HttpChannel httpchan; Console.WriteLine("\nStarting server in WellKnownObjectMode {0}\n", ObjMode.ToString()); switch (ChanKind) { case ChannelKind.Http: httpchan = new HttpChannel(Server.HTTPPORT); ChannelServices.RegisterChannel(httpchan); break; case ChannelKind.TCP: tcpchan = new TcpChannel(Server.TCPPORT); ChannelServices.RegisterChannel(tcpchan); break; case ChannelKind.Both: httpchan = new HttpChannel(Server.HTTPPORT); ChannelServices.RegisterChannel(httpchan); tcpchan = new TcpChannel(Server.TCPPORT); ChannelServices.RegisterChannel(tcpchan); break; default: throw new System.InvalidOperationException("Unexpected Channel kind in Server.Run()"); }//switch RemotingConfiguration.RegisterWellKnownServiceType(ObjType, "SayHello", ObjMode); System.Console.WriteLine("Hit <enter> to exit..."); System.Console.ReadLine(); return; }
public Task <Channel> PostChannelAsync(string channelName, string description, ChannelKind kind) { var r = new HttpRequestMessage(HttpMethod.Post, EndPoint + $"/v1/channels"); var d = new[] { new KeyValuePair <string, string>("channel[channel_name]", channelName), new KeyValuePair <string, string>("channel[description]", description), new KeyValuePair <string, string>("channel[kind]", kind.ToApiString()) }; r.Content = new FormUrlEncodedContent(d); return(SendAsync <Channel>(r)); }
public bool this[ChannelKind channelID] { get { KeyCode?l_keyToCheck = null; switch (channelID) { case ChannelKind.Jump: l_keyToCheck = KeyCode.Space; break; case ChannelKind.Kick: break; case ChannelKind.Crouch: l_keyToCheck = KeyCode.LeftShift; break; case ChannelKind.Punch: break; case ChannelKind.Forward: l_keyToCheck = KeyCode.W; break; case ChannelKind.Backward: l_keyToCheck = KeyCode.S; break; case ChannelKind.Left: l_keyToCheck = KeyCode.A; break; case ChannelKind.Right: l_keyToCheck = KeyCode.D; break; case ChannelKind.Any: { foreach (ChannelKind kind in System.Enum.GetValues(typeof(ChannelKind))) { if (kind != ChannelKind.Any) { bool l_v = this[kind]; if (l_v) { return(l_v); } } } } break; default: //multiple options here { bool?l_v = null; foreach (ChannelKind kind in System.Enum.GetValues(typeof(ChannelKind))) { if (kind != ChannelKind.Any) { if ((channelID & kind) != 0) { if (l_v == null) { l_v = this[kind]; } l_v = l_v.Value && this[kind]; } } } return(l_v ?? false); } break; } return(l_keyToCheck != null && Input.GetKey(l_keyToCheck.Value)); } set { //cant set player input } }