Advertisement
Guest User

NS Client

a guest
Apr 22nd, 2014
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. // Copyright (C) Paul Becker, - All Rights Reserved
  2. // Unauthorized copying of this file, via any medium is strictly prohibited
  3. // Proprietary and confidential
  4. // Written by Paul Becker <paul.becker1@gmx.de>, 08:13
  5.  
  6. #region usings
  7.  
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Net.Sockets;
  11.  
  12. #endregion
  13.  
  14. namespace Assets.Network
  15. {
  16.     internal class NetworkService
  17.     {
  18.         public static Connection CnxPreAlloc;
  19.  
  20.         public static void Start()
  21.         {
  22.             PacketHolder.Load();
  23.             BeginAccept();
  24.         }
  25.  
  26.         private static void BeginAccept()
  27.         {
  28.             try
  29.             {
  30.                 CnxPreAlloc = new Connection(new TcpClient("127.0.0.1", 2106));
  31.                 UnityEngine.Debug.Log("Connected to the server");
  32.                 CnxPreAlloc.OnConnect();
  33.             }
  34.             catch (Exception)
  35.             {
  36.                 CnxPreAlloc = new Connection(null);
  37.                 UnityEngine.Debug.Log("No Server avaible, reconnect later...");
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement