예제 #1
0
 public ServicesOpenSocketSendDataScenarioResult(
     bool scenarioSucceeded,
     ServicesOpenSocketScenarioResult openSocketResult
     )
 {
     ScenarioSucceeded = scenarioSucceeded;
     OpenSocketResult  = openSocketResult;
 }
예제 #2
0
        private void ExecuteInternal()
        {
            try
            {
                var openSocketScenario = new ServicesOpenSocketScenario(
                    senderWFDController,
                    receiverWFDController,
                    new ServicesOpenSocketParameters(
                        socketDataParameters.SenderSessionHandle,
                        socketDataParameters.ReceiverSessionHandle,
                        socketDataParameters.Protocol,
                        socketDataParameters.Port
                        )
                    );
                openSocketResult = openSocketScenario.Execute();

                if (!openSocketResult.ScenarioSucceeded)
                {
                    throw new Exception("Open Socket failed!");
                }

                ServicesSendDataScenario sendDataScenario = null;

                if (socketDataParameters.Protocol == WiFiDirectServiceIPProtocol.Tcp)
                {
                    sendDataScenario = new ServicesSendDataScenario(
                        senderWFDController,
                        receiverWFDController,
                        new ServicesSendDataParameters(
                            socketDataParameters.SenderSessionHandle,
                            openSocketResult.SenderSocketHandle,
                            socketDataParameters.ReceiverSessionHandle,
                            openSocketResult.ReceiverSocketHandle,
                            socketDataParameters.DataSize
                            )
                        );
                }
                else
                {
                    // special case for UDP, just send on the opposite side for now
                    sendDataScenario = new ServicesSendDataScenario(
                        receiverWFDController,
                        senderWFDController,
                        new ServicesSendDataParameters(
                            socketDataParameters.ReceiverSessionHandle,
                            openSocketResult.ReceiverSocketHandle,
                            socketDataParameters.SenderSessionHandle,
                            openSocketResult.SenderSocketHandle,
                            socketDataParameters.DataSize
                            )
                        );
                }
                ServicesSendDataScenarioResult sendDataResult = sendDataScenario.Execute();

                if (!sendDataResult.ScenarioSucceeded)
                {
                    throw new Exception("Send Data failed!");
                }

                succeeded = true;
            }
            catch (Exception e)
            {
                WiFiDirectTestLogger.Error("Caught exception while executing service open socket scenario: {0}", e);
            }
        }