コード例 #1
0
 def create_url(cls, host, port=None, is_secure=False):
     if port is None:
         return Uri(host)
     else:
         scheme = 'wss' if is_secure else 'ws'
         builder = UriBuilder(scheme, host, port)
         return builder.Uri
コード例 #2
0
ファイル: client_net.py プロジェクト: tkmmark/compas_cloud
    def __init__(self, host='127.0.0.1', port=9000):
        """init the client, wait until it successfully connected to server"""
        scheme = 'ws'
        builder = UriBuilder(scheme, host, port)
        uri = builder.Uri

        self.token = CancellationTokenSource().Token
        self.socket = ClientWebSocket()
        task = self.socket.ConnectAsync(uri, self.token)
        task.Wait()
        print('connected to cloud using .NET client!')
コード例 #3
0
 def __init__(self, fileName):
     scriptEnv = Python.CreateRuntime()
     self.fileName = fileName
     self.engine = scriptEnv.GetEngine("python")        
     self.context = HostingHelpers.GetLanguageContext(self.engine) 
     scriptEnv.LoadAssembly(Type.GetType("System.String").Assembly) #mscorlib.dll
     scriptEnv.LoadAssembly(UriBuilder().GetType().Assembly)  #System.dll
             
     self.InitializePath()
     
     executable = Assembly.GetEntryAssembly().Location
     prefix = Path.GetDirectoryName(executable)
     
     self.context.SystemState.executable = executable
     self.context.SystemState.exec_prefix = self.context.SystemState.prefix = prefix
     
     import imp
     mod = imp.new_module('__main__')
     mod.__file__ = fileName
     mod.__builtins__ = sys.modules['__builtin__']
     self.context.SystemState.modules['__main__'] = mod
     self.mainScope = scriptEnv.CreateScope(mod.__dict__)