IS_OK









How do I use I S_ O K
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: ChatGui.cs Copy
95     public void Update()
96     {
97         if (this.chatClient != null)
98         {
99             this.chatClient.Service(); // make sure to call this regularly! it limits effort internally, so calling often is ok!
100         }
101     }
File name: AccountService.cs Copy
48     public static bool Validator(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors policyErrors)
49     {
50         return true; // any certificate is ok in this case
51     }
File name: NetworkingPeer.cs Copy
1411     public void OnStatusChanged(StatusCode statusCode)
1412     {
1413         if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
1414             Debug.Log(string.Format("OnStatusChanged: {0}", statusCode.ToString()));
1415
1416         switch (statusCode)
1417         {
1418             case StatusCode.Connect:
1419                 if (this.State == global::PeerState.ConnectingToNameServer)
1420                 {
1421                     if (PhotonNetwork.logLevel >= PhotonLogLevel.Full)
1422                         Debug.Log("Connected to NameServer.");
1423
1424                     this.server = ServerConnection.NameServer;
1425                     if (this.CustomAuthenticationValues != null)
1426                     {
1427                         this.CustomAuthenticationValues.Secret = null; // when connecting to NameServer, invalidate any auth values
1428                     }
1429                 }
1430
1431                 if (this.State == global::PeerState.ConnectingToGameserver)
1432                 {
1433                     if (PhotonNetwork.logLevel >= PhotonLogLevel.Full)
1434                         Debug.Log("Connected to gameserver.");
1435
1436                     this.server = ServerConnection.GameServer;
1437                     this.State = global::PeerState.ConnectedToGameserver;
1438                 }
1439
1440                 if (this.State == global::PeerState.ConnectingToMasterserver)
1441                 {
1442                     if (PhotonNetwork.logLevel >= PhotonLogLevel.Full)
1443                         Debug.Log("Connected to masterserver.");
1444
1445                     this.server = ServerConnection.MasterServer;
1446                     this.State = global::PeerState.ConnectedToMaster;
1447
1448                     if (this.IsInitialConnect)
1449                     {
1450                         this.IsInitialConnect = false; // after handling potential initial-connect issues with special messages, we are now sure we can reach a server
1451                         SendMonoMessage(PhotonNetworkingMessage.OnConnectedToPhoton);
1452                     }
1453                 }
1454
1455                 this.EstablishEncryption(); // always enable encryption
1456
1457                 if (this.IsAuthorizeSecretAvailable)
1458                 {
1459                     // if we have a token we don't have to wait for encryption (it is encrypted anyways, so encryption is just optional later on)
1460                     this.didAuthenticate = this.OpAuthenticate(this.mAppId, this.mAppVersionPun, this.PlayerName, this.CustomAuthenticationValues, this.CloudRegion.ToString());
1461                     if (this.didAuthenticate)
1462                     {
1463                         this.State = global::PeerState.Authenticating;
1464                     }
1465                 }
1466                 break;
1467
1468             case StatusCode.EncryptionEstablished:
1469                 // on nameserver, the "process" is stopped here, so the developer/game can either get regions or authenticate with a specific region
1470                 if (this.server == ServerConnection.NameServer)
1471                 {
1472                     this.State = global::PeerState.ConnectedToNameServer;
1473
1474                     if (!this.didAuthenticate && this.CloudRegion == CloudRegionCode.none)
1475                     {
1476                         // this client is not setup to connect to a default region. find out which regions there are!
1477                         this.OpGetRegions(this.mAppId);
1478                     }
1479                 }
1480
1481                 // we might need to authenticate automatically now, so the client can do anything at all
1482                 if (!this.didAuthenticate && (!this.IsUsingNameServer || this.CloudRegion != CloudRegionCode.none))
1483                 {
1484                     // once encryption is availble, the client should send one (secure) authenticate. it includes the AppId (which identifies your app on the Photon Cloud)
1485                     this.didAuthenticate = this.OpAuthenticate(this.mAppId, this.mAppVersionPun, this.PlayerName, this.CustomAuthenticationValues, this.CloudRegion.ToString());
1486                     if (this.didAuthenticate)
1487                     {
1488                         this.State = global::PeerState.Authenticating;
1489                     }
1490                 }
1491                 break;
1492
1493             case StatusCode.EncryptionFailedToEstablish:
1494                 Debug.LogError("Encryption wasn't established: " + statusCode + ". Going to authenticate anyways.");
1495                 this.OpAuthenticate(this.mAppId, this.mAppVersionPun, this.PlayerName, this.CustomAuthenticationValues, this.CloudRegion.ToString()); // TODO: check if there are alternatives
1496                 break;
1497
1498             case StatusCode.Disconnect:
1499                 this.didAuthenticate = false;
1500                 this.isFetchingFriends = false;
1501                 if (server == ServerConnection.GameServer) this.LeftRoomCleanup();
1502                 if (server == ServerConnection.MasterServer) this.LeftLobbyCleanup();
1503
1504                 if (this.State == global::PeerState.DisconnectingFromMasterserver)
1505                 {
1506                     if (this.Connect(this.mGameserver, ServerConnection.GameServer))
1507                     {
1508                         this.State = global::PeerState.ConnectingToGameserver;
1509                     }
1510                 }
1511                 else if (this.State == global::PeerState.DisconnectingFromGameserver || this.State == global::PeerState.DisconnectingFromNameServer)
1512                 {
1513                     if (this.Connect(this.MasterServerAddress, ServerConnection.MasterServer))
1514                     {
1515                         this.State = global::PeerState.ConnectingToMasterserver;
1516                     }
1517                 }
1518                 else
1519                 {
1520                     if (this.CustomAuthenticationValues != null)
1521                     {
1522                         this.CustomAuthenticationValues.Secret = null; // invalidate any custom auth secrets
1523                     }
1524
1525                     this.State = global::PeerState.PeerCreated; // if we set another state here, we could keep clients from connecting in OnDisconnectedFromPhoton right here.
1526                     SendMonoMessage(PhotonNetworkingMessage.OnDisconnectedFromPhoton);
1527                 }
1528                 break;
1529
1530             case StatusCode.SecurityExceptionOnConnect:
1531             case StatusCode.ExceptionOnConnect:
1532                 this.State = global::PeerState.PeerCreated;
1533                 if (this.CustomAuthenticationValues != null)
1534                 {
1535                     this.CustomAuthenticationValues.Secret = null; // invalidate any custom auth secrets
1536                 }
1537
1538                 DisconnectCause cause = (DisconnectCause)statusCode;
1539                 SendMonoMessage(PhotonNetworkingMessage.OnFailedToConnectToPhoton, cause);
1540                 break;
1541
1542             case StatusCode.Exception:
1543                 if (this.IsInitialConnect)
1544                 {
1545                     Debug.LogError("Exception while connecting to: " + this.ServerAddress + ". Check if the server is available.");
1546                     if (this.ServerAddress == null || this.ServerAddress.StartsWith("127.0.0.1"))
1547                     {
1548                         Debug.LogWarning("The server address is 127.0.0.1 (localhost): Make sure the server is running on this machine. Android and iOS emulators have their own localhost.");
1549                         if (this.ServerAddress == this.mGameserver)
1550                         {
1551                             Debug.LogWarning("This might be a misconfiguration in the game server config. You need to edit it to a (public) address.");
1552                         }
1553                     }
1554
1555                     this.State = global::PeerState.PeerCreated;
1556                     cause = (DisconnectCause)statusCode;
1557                     SendMonoMessage(PhotonNetworkingMessage.OnFailedToConnectToPhoton, cause);
1558                 }
1559                 else
1560                 {
1561                     this.State = global::PeerState.PeerCreated;
1562
1563                     cause = (DisconnectCause)statusCode;
1564                     SendMonoMessage(PhotonNetworkingMessage.OnConnectionFail, cause);
1565                 }
1566
1567                 this.Disconnect();
1568                 break;
1569
1570             case StatusCode.TimeoutDisconnect:
1571             case StatusCode.ExceptionOnReceive:
1572             case StatusCode.DisconnectByServer:
1573             case StatusCode.DisconnectByServerLogic:
1574             case StatusCode.DisconnectByServerUserLimit:
1575                 if (this.IsInitialConnect)
1576                 {
1577                     Debug.LogWarning(statusCode + " while connecting to: " + this.ServerAddress + ". Check if the server is available.");
1578
1579                     cause = (DisconnectCause)statusCode;
1580                     SendMonoMessage(PhotonNetworkingMessage.OnFailedToConnectToPhoton, cause);
1581                 }
1582                 else
1583                 {
1584                     cause = (DisconnectCause)statusCode;
1585                     SendMonoMessage(PhotonNetworkingMessage.OnConnectionFail, cause);
1586                 }
1587                 if (this.CustomAuthenticationValues != null)
1588                 {
1589                     this.CustomAuthenticationValues.Secret = null; // invalidate any custom auth secrets
1590                 }
1591
1592                 this.Disconnect();
1593                 break;
1594
1595             case StatusCode.SendError:
1596                 // this.mListener.clientErrorReturn(statusCode);
1597                 break;
1598
1599             case StatusCode.QueueOutgoingReliableWarning:
1600             case StatusCode.QueueOutgoingUnreliableWarning:
1601             case StatusCode.QueueOutgoingAcksWarning:
1602             case StatusCode.QueueSentWarning:
1603                 // this.mListener.warningReturn(statusCode);
1604                 break;
1605
1606             case StatusCode.QueueIncomingReliableWarning:
1607             case StatusCode.QueueIncomingUnreliableWarning:
1608                 Debug.Log(statusCode + ". This client buffers many incoming messages. This is OK temporarily. With lots of these warnings, check if you send too much or execute messages too slow. " + (PhotonNetwork.isMessageQueueRunning? "":"Your isMessageQueueRunning is false. This can cause the issue temporarily.") );
1609                 break;
1610
1611             // // TCP "routing" is an option of Photon that's not currently needed (or supported) by PUN
1612             //case StatusCode.TcpRouterResponseOk:
1613             // break;
1614             //case StatusCode.TcpRouterResponseEndpointUnknown:
1615             //case StatusCode.TcpRouterResponseNodeIdUnknown:
1616             //case StatusCode.TcpRouterResponseNodeNotReady:
1617
1618             // this.DebugReturn(DebugLevel.ERROR, "Unexpected router response: " + statusCode);
1619             // break;
1620
1621             default:
1622
1623                 // this.mListener.serverErrorReturn(statusCode.value());
1624                 Debug.LogError("Received unknown status code: " + statusCode);
1625                 break;
1626         }
1627
1628         this.externalListener.OnStatusChanged(statusCode);
1629     }
File name: NetworkingPeer.cs Copy
3339     private void OnSerializeRead(Hashtable data, PhotonPlayer sender, int networkTime, short correctPrefix)
3340     {
3341         // read view ID from key (byte)0: a int-array (PUN 1.17++)
3342         int viewID = (int)data[(byte)0];
3343
3344
3345         PhotonView view = this.GetPhotonView(viewID);
3346         if (view == null)
3347         {
3348             Debug.LogWarning("Received OnSerialization for view ID " + viewID + ". We have no such PhotonView! Ignored this if you're leaving a room. State: " + this.State);
3349             return;
3350         }
3351
3352         if (view.prefix > 0 && correctPrefix != view.prefix)
3353         {
3354             Debug.LogError("Received OnSerialization for view ID " + viewID + " with prefix " + correctPrefix + ". Our prefix is " + view.prefix);
3355             return;
3356         }
3357
3358         // SetReceiving filtering
3359         if (view.group != 0 && !this.allowedReceivingGroups.Contains(view.group))
3360         {
3361             return; // Ignore group
3362         }
3363
3364
3365         if (view.synchronization == ViewSynchronization.ReliableDeltaCompressed)
3366         {
3367             if (!this.DeltaCompressionRead(view, data))
3368             {
3369                 // Skip this packet as we haven't got received complete-copy of this view yet.
3370                 if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
3371                     Debug.Log("Skipping packet for " + view.name + " [" + view.viewID + "] as we haven't received a full packet for delta compression yet. This is OK if it happens for the first few frames after joining a game.");
3372                 return;
3373             }
3374
3375             // store last received for delta-compression usage
3376             view.lastOnSerializeDataReceived = data[(byte)1] as object[];
3377         }
3378
3379         if (sender.ID != view.ownerId)
3380         {
3381             if (!view.isSceneView || !sender.isMasterClient)
3382             {
3383                 // obviously the owner changed and we didn't yet notice.
3384                 Debug.Log("Adjusting owner to sender of updates. From: " + view.ownerId + " to: " + sender.ID);
3385                 view.ownerId = sender.ID;
3386             }
3387         }
3388
3389         object[] contents = data[(byte)1] as object[];
3390         PhotonStream pStream = new PhotonStream(false, contents);
3391         PhotonMessageInfo info = new PhotonMessageInfo(sender, networkTime, view);
3392
3393         view.DeserializeView( pStream, info );
3394     }
File name: frmColor.cs Copy
86   private void InitializeComponent()
87   {
88             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ColorInput));
89             this.Blue = new System.Windows.Forms.TextBox();
90             this.label4 = new System.Windows.Forms.Label();
91             this.Green = new System.Windows.Forms.TextBox();
92             this.label3 = new System.Windows.Forms.Label();
93             this.Red = new System.Windows.Forms.TextBox();
94            this.label2 = new System.Windows.Forms.Label();
95             this.label1 = new System.Windows.Forms.Label();
96             this.Cancel = new System.Windows.Forms.Button();
97             this.OK = new System.Windows.Forms.Button();
98             this.SuspendLayout();
99             //
100             // Blue
101             //
102             this.Blue.Location = new System.Drawing.Point(103, 112);
103             this.Blue.Name = "Blue";
104             this.Blue.Size = new System.Drawing.Size(100, 20);
105             this.Blue.TabIndex = 17;
106             ////
107             // label4
108             //
109             this.label4.ForeColor = System.Drawing.Color.Blue;
110             this.label4.Location = new System.Drawing.Point(32, 112);
111             this.label4.Name = "label4";
112             this.label4.Size = new System.Drawing.Size(32, 16);
113             this.label4.TabIndex = 16;
114             this.label4.Text = "Blue";
115            // //
116            // // Green
117            // //
118             this.Green.Location = new System.Drawing.Point(103, 80);
119             this.Green.Name = "Green";
120             this.Green.Size = new System.Drawing.Size(100, 20);
121             this.Green.TabIndex = 15;
122             //
123            // // label3
124            // //
125             this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
126             this.label3.Location = new System.Drawing.Point(32, 80);
127             this.label3.Name = "label3";
128             this.label3.Size = new System.Drawing.Size(32, 16);
129             this.label3.TabIndex = 14;
130             this.label3.Text = "Green";
131             //
132            // // Red
133            // //
134             this.Red.Location = new System.Drawing.Point(103, 48);
135             this.Red.Name = "Red";
136             this.Red.Size = new System.Drawing.Size(100, 20);
137             this.Red.TabIndex = 13;
138            // //
139            // // label2
140            // //
141             this.label2.ForeColor = System.Drawing.Color.Red;
142             this.label2.Location = new System.Drawing.Point(32, 48);
143             this.label2.Name = "label2";
144             this.label2.Size = new System.Drawing.Size(32, 16);
145             this.label2.TabIndex = 12;
146             this.label2.Text = "Red";
147             //
148            // // label1
149            // //
150             this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
151             this.label1.ForeColor = System.Drawing.Color.Blue;
152             this.label1.Location = new System.Drawing.Point(16, 16);
153             this.label1.Name = "label1";
154             this.label1.Size = new System.Drawing.Size(281, 24);
155             this.label1.TabIndex = 11;
156             this.label1.Text = "Nhập các giá trị màu từ -255 đến 255";
157             // this.label1.Click += new System.EventHandler(this.label1_Click);
158            // //
159            // // Cancel
160            // //
161             this.Cancel.Location = new System.Drawing.Point(176, 178);
162             this.Cancel.Name = "Cancel";
163             this.Cancel.Size = new System.Drawing.Size(75, 23);
164             this.Cancel.TabIndex = 9;
165             this.Cancel.Text = "Bỏ qua";
166             //
167            // // OK
168            // //
169             this.OK.Location = new System.Drawing.Point(19, 178);
170             this.OK.Name = "OK";
171             this.OK.Size = new System.Drawing.Size(75, 23);
172             this.OK.TabIndex = 10;
173             this.OK.Text = "Đồng ý";
174            // this.OK.Click += new System.EventHandler(this.OK_Click);
175             //
176             // ColorInput
177             //
178             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
179             this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
180             this.ClientSize = new System.Drawing.Size(309, 226);
181             this.Controls.Add(this.Blue);
182             this.Controls.Add(this.label4);
183             this.Controls.Add(this.Green);
184             this.Controls.Add(this.label3);
185             this.Controls.Add(this.Red);
186             this.Controls.Add(this.label2);
187             this.Controls.Add(this.label1);
188             this.Controls.Add(this.OK);
189             this.Controls.Add(this.Cancel);
190             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
191             this.Name = "ColorInput";
192             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
193             this.Text = "CHON MAU";
194             //this.Load += new System.EventHandler(this.ColorInput_Load);
195             this.ResumeLayout(false);
196             this.PerformLayout();
197
198   }

IS_OK 113 lượt xem

Gõ tìm kiếm nhanh...