通过蜂窝网络的Peer-2-peer或客户端/服务器连接来连接2个android设备

时间:2021-04-07 00:47:08

I want make an android app which connects 2 android phones over cellphone network. Sort of like a chat app. I am very new to android. Here is an visual of what i need-

我想制作一个Android应用程序,通过手机网络连接2个Android手机。有点像聊天应用程序。我对android很新。这是我需要的视觉 -

AndroidPhone1--------->send request(message saying yes/no) to connect over cellphone network------>AndroidPhone2

AndroidPhone2 accepts

AndroidPhone1<--------->connection over cellphone network<------>AndroidPhone2

or

AndroidPhone1---->send request to connect over cellphone network------>Server

Server -----> send request------AndroidPhone2

AndroidPhone2 accepts

AndroidPhone1<--------->Server<-------->AndroidPhone2

I researched a little and heard xmpp but not clear to me. Any pointer to start such as socket,AWS or anything is greatly appreciated. Thank you.

我研究了一下并听到了xmpp,但对我来说并不清楚。任何指向启动的指针,如socket,AWS或任何东西都非常感谢。谢谢。

1 个解决方案

#1


1  

For your requirement you can use the newly announced service called AWS AppSync along with DynamoDB. AppSync supports subscribers through web sockets, which allows full duplex communication and push of messages from both client->server and server->client.

根据您的要求,您可以使用新发布的名为AWS AppSync的服务以及DynamoDB。 AppSync通过Web套接字支持订户,该套接字允许从客户端 - >服务器和服务器 - >客户端进行全双工通信和推送消息。

  1. Request for AppSync preview from your AWS account. Request form link.
  2. 从您的AWS账户请求AppSync预览。请求表单链接。

  3. Create the schemas in AppSync using GraphQL.
  4. 使用GraphQL在AppSync中创建模式。

  5. Create the storage and other connections.(Depending on your use case, you can go from two tier to three tier backend. e.g if you have further processing and rules to be applied, you can go for API Gateway -> Lambda -> DynamoDB and Stream from there to AppSync, or for simple use case, you can directly push messages to DynamoDB given that you have temporal access tokens with fine-grained access control to DynamoDB. Note: Here you can use AWS Cognito to get those tokens also supporting the authentication)
  6. 创建存储和其他连接。(根据您的使用情况,您可以从两层到三层后端。例如,如果您有进一步的处理和规则要应用,您可以使用API​​网关 - > Lambda - > DynamoDB和从那里流到AppSync,或者对于简单的用例,您可以直接将消息推送到DynamoDB,前提是您具有对DynamoDB具有细粒度访问控制的临时访问令。注意:在这里您可以使用AWS Cognito来获取那些也支持验证)

  7. Write a mobile app subscribing with App Sync and Pushing messages to the backend.
  8. 编写一个订阅App Sync并将消息推送到后端的移动应用程序。

There are two more options you can consider.

您还可以考虑另外两个选项。

  • Using Cognito Sync.
  • 使用Cognito Sync。

  • Using the previously mentioned stack without AppSync but with AWS IOT Websockets.
  • 使用前面提到的没有AppSync但使用AWS IOT Websockets的堆栈。

#1


1  

For your requirement you can use the newly announced service called AWS AppSync along with DynamoDB. AppSync supports subscribers through web sockets, which allows full duplex communication and push of messages from both client->server and server->client.

根据您的要求,您可以使用新发布的名为AWS AppSync的服务以及DynamoDB。 AppSync通过Web套接字支持订户,该套接字允许从客户端 - >服务器和服务器 - >客户端进行全双工通信和推送消息。

  1. Request for AppSync preview from your AWS account. Request form link.
  2. 从您的AWS账户请求AppSync预览。请求表单链接。

  3. Create the schemas in AppSync using GraphQL.
  4. 使用GraphQL在AppSync中创建模式。

  5. Create the storage and other connections.(Depending on your use case, you can go from two tier to three tier backend. e.g if you have further processing and rules to be applied, you can go for API Gateway -> Lambda -> DynamoDB and Stream from there to AppSync, or for simple use case, you can directly push messages to DynamoDB given that you have temporal access tokens with fine-grained access control to DynamoDB. Note: Here you can use AWS Cognito to get those tokens also supporting the authentication)
  6. 创建存储和其他连接。(根据您的使用情况,您可以从两层到三层后端。例如,如果您有进一步的处理和规则要应用,您可以使用API​​网关 - > Lambda - > DynamoDB和从那里流到AppSync,或者对于简单的用例,您可以直接将消息推送到DynamoDB,前提是您具有对DynamoDB具有细粒度访问控制的临时访问令。注意:在这里您可以使用AWS Cognito来获取那些也支持验证)

  7. Write a mobile app subscribing with App Sync and Pushing messages to the backend.
  8. 编写一个订阅App Sync并将消息推送到后端的移动应用程序。

There are two more options you can consider.

您还可以考虑另外两个选项。

  • Using Cognito Sync.
  • 使用Cognito Sync。

  • Using the previously mentioned stack without AppSync but with AWS IOT Websockets.
  • 使用前面提到的没有AppSync但使用AWS IOT Websockets的堆栈。